Merge pull request #306 from boglin/multi_init_cmd
Multi-statement init_command causes subsequent query to fail
This commit is contained in:
@@ -841,6 +841,7 @@ class Connection(object):
|
|||||||
if self.init_command is not None:
|
if self.init_command is not None:
|
||||||
c = self.cursor()
|
c = self.cursor()
|
||||||
c.execute(self.init_command)
|
c.execute(self.init_command)
|
||||||
|
c.close()
|
||||||
self.commit()
|
self.commit()
|
||||||
|
|
||||||
if self.autocommit_mode is not None:
|
if self.autocommit_mode is not None:
|
||||||
|
|||||||
@@ -69,3 +69,13 @@ class TestConnection(base.PyMySQLTestCase):
|
|||||||
# error occures while reading, not writing because of socket buffer.
|
# error occures while reading, not writing because of socket buffer.
|
||||||
#self.assertEquals(cm.exception.args[0], 2006)
|
#self.assertEquals(cm.exception.args[0], 2006)
|
||||||
self.assertIn(cm.exception.args[0], (2006, 2013))
|
self.assertIn(cm.exception.args[0], (2006, 2013))
|
||||||
|
|
||||||
|
def test_init_command(self):
|
||||||
|
conn = pymysql.connect(
|
||||||
|
init_command='SELECT "bar"; SELECT "baz"',
|
||||||
|
**self.databases[0]
|
||||||
|
)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute('select "foobar";')
|
||||||
|
self.assertEqual(('foobar',), c.fetchone())
|
||||||
|
conn.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user