

def test_executemany(self):
    con = self._connect()
    try:
        cur = con.cursor()
        self.executeDDL1(cur)
        largs = [("Cooper's",), ("Boag's",)]
        margs = [{
            'beer': "Cooper's",
        }, {
            'beer': "Boag's",
        }]
        if (self.driver.paramstyle == 'qmark'):
            cur.executemany(('insert into %sbooze values (?)' % self.table_prefix), largs)
        elif (self.driver.paramstyle == 'numeric'):
            cur.executemany(('insert into %sbooze values (:1)' % self.table_prefix), largs)
        elif (self.driver.paramstyle == 'named'):
            cur.executemany(('insert into %sbooze values (:beer)' % self.table_prefix), margs)
        elif (self.driver.paramstyle == 'format'):
            cur.executemany(('insert into %sbooze values (%%s)' % self.table_prefix), largs)
        elif (self.driver.paramstyle == 'pyformat'):
            cur.executemany(('insert into %sbooze values (%%(beer)s)' % self.table_prefix), margs)
        else:
            self.fail('Unknown paramstyle')
        self.assertTrue((cur.rowcount in ((- 1), 2)), ('insert using cursor.executemany set cursor.rowcount to incorrect value %r' % cur.rowcount))
        cur.execute(('select name from %sbooze' % self.table_prefix))
        res = cur.fetchall()
        self.assertEqual(len(res), 2, 'cursor.fetchall retrieved incorrect number of rows')
        beers = [res[0][0], res[1][0]]
        beers.sort()
        self.assertEqual(beers[0], "Boag's", 'incorrect data retrieved')
        self.assertEqual(beers[1], "Cooper's", 'incorrect data retrieved')
    finally:
        con.close()

dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/MySQL-python-1.2.5/tests/dbapi20.py DatabaseAPI20Test.test_executemany/original