1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#!/usr/bin/env python -O
# -*- coding: utf-8 -*-
import datetime
import unittest
from test.base_test import create_connection, is_maxscale
class CursorMySQLTest(unittest.TestCase):
def setUp(self):
self.connection = create_connection()
def tearDown(self):
del self.connection
def test_parameter(self):
if is_maxscale():
self.skipTest("MAXSCALE doesn't support BULK yet")
cursor = self.connection.cursor()
cursor.execute("CREATE TEMPORARY TABLE test_parameter("
"a int auto_increment primary key not "
"null, b int, c int, d varchar(20),e date)")
cursor.execute("SET @@autocommit=0")
list_in = []
for i in range(1, 30000):
row = (i, i, i, "bar", datetime.date(2019, 1, 1))
list_in.append(row)
cursor.executemany("INSERT INTO test_parameter VALUES "
"(%s,%s,%s,%s,%s)", list_in)
self.connection.commit()
cursor.execute("SELECT * FROM test_parameter order by a")
list_out = cursor.fetchall()
self.assertEqual(list_in, list_out)
cursor.close()
if __name__ == '__main__':
unittest.main()
|