mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-04 08:04:45 +00:00

mariadb.indicator_null, mariadb.indicator_default, mariadb.indictor.ignore Added support for Tuple and list objects: List and Tuple will be stored as blob in a dynamic column
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
#!/usr/bin/env python -O
|
|
|
|
import mysql.connector
|
|
import datetime
|
|
import unittest
|
|
|
|
class CursorTest(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
self.connection= mysql.connector.connect(user='root', database='test')
|
|
|
|
def tearDown(self):
|
|
self.connection.close()
|
|
del self.connection
|
|
|
|
def test_parameter(self):
|
|
cursor= self.connection.cursor()
|
|
cursor.execute("CREATE OR REPLACE TABLE t1(a int auto_increment primary key not null, b int, c int, d varchar(20),e date)")
|
|
cursor.execute("SET @@autocommit=0");
|
|
c = (1,2,3, "bar", datetime.date(2018,11,11))
|
|
list_in= []
|
|
for i in range(1,300001):
|
|
row= (i,i,i,"bar", datetime.date(2019,1,1))
|
|
list_in.append(row)
|
|
cursor.executemany("INSERT INTO t1 VALUES (%s,%s,%s,%s,%s)", list_in)
|
|
print("rows inserted:", len(list_in))
|
|
self.connection.commit()
|
|
cursor.execute("SELECT * FROM t1 order by a")
|
|
list_out= cursor.fetchall()
|
|
print("rows fetched: ", len(list_out))
|
|
self.assertEqual(list_in,list_out)
|
|
|
|
cursor.close()
|
|
|