File: test_cursor_mysql.py

package info (click to toggle)
mariadb-connector-python 1.1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 812 kB
  • sloc: python: 6,246; ansic: 4,971; sh: 23; makefile: 14
file content (42 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (2)
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()