Python pymysql 模块,Binary() 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用pymysql.Binary()

项目:watchmen    作者:lycclsltt    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:touch-pay-client    作者:HackPucBemobi    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:bawk    作者:jttwnsnd    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:rekall-agent-server    作者:rekall-innovations    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:deb-python-pymysql    作者:openstack    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:ServerlessCrawler-VancouverRealState    作者:MarcelloLins    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:metrics    作者:Jeremy-Friedman    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:prophessor    作者:paulhauner    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:blog_flask    作者:momantai    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:flask    作者:bobohope    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:power-pi    作者:Knapsacks    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))
项目:power-pi    作者:Knapsacks    | 项目源码 | 文件源码
def test_issue_364(self):
        """ Test mixed unicode/binary arguments in executemany. """
        conn = pymysql.connect(charset="utf8", **self.databases[0])
        self.safe_create_table(
            conn, "issue364",
            "create table issue364 (value_1 binary(3), value_2 varchar(3)) "
            "engine=InnoDB default charset=utf8")

        sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
        usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
        values = [pymysql.Binary(b"\x00\xff\x00"), u"\xe4\xf6\xfc"]

        # test single insert and select
        cur = conn.cursor()
        cur.execute(sql, args=values)
        cur.execute("select * from issue364")
        self.assertEqual(cur.fetchone(), tuple(values))

        # test single insert unicode query
        cur.execute(usql, args=values)

        # test multi insert and select
        cur.executemany(sql, args=(values, values, values))
        cur.execute("select * from issue364")
        for row in cur.fetchall():
            self.assertEqual(row, tuple(values))

        # test multi insert with unicode query
        cur.executemany(usql, args=(values, values, values))