Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Calling connection's method during multiple result breaks command sync #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions 14 pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,10 +1021,13 @@ def _execute_command(self, command, sql):

# If the last query was unbuffered, make sure it finishes before
# sending new commands
if self._result is not None and self._result.unbuffered_active:
warnings.warn("Previous unbuffered result was left incomplete")
self._result._finish_unbuffered_query()
self._result = None
if self._result is not None:
if self._result.unbuffered_active:
warnings.warn("Previous unbuffered result was left incomplete")
self._result._finish_unbuffered_query()
while self._result.has_next:
self.next_result()
self._result = None

if isinstance(sql, text_type):
sql = sql.encode(self.encoding)
Expand Down Expand Up @@ -1113,9 +1116,6 @@ def _request_authentication(self):
self.write_packet(data)
auth_packet = self._read_packet()

#TODO: ok packet or error packet?


def _process_auth(self, plugin_name, auth_packet):
plugin_class = self._auth_plugin_map.get(plugin_name)
if not plugin_class:
Expand Down
10 changes: 9 additions & 1 deletion 10 pymysql/tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def test_connection_gone_away(self):
with self.assertRaises(pymysql.OperationalError) as cm:
cur.execute("SELECT 1+1")
# error occures while reading, not writing because of socket buffer.
#self.assertEquals(cm.exception.args[0], 2006)
#self.assertEqual(cm.exception.args[0], 2006)
self.assertIn(cm.exception.args[0], (2006, 2013))

def test_init_command(self):
Expand Down Expand Up @@ -566,3 +566,11 @@ def test_previous_cursor_not_closed(self):
cur2 = con.cursor()
with self.assertRaises(pymysql.ProgrammingError):
cur2.execute("SELECT 3")

def test_commit_during_multi_result(self):
con = self.connections[0]
cur = con.cursor()
cur.execute("SELECT 1; SELECT 2")
con.commit()
cur.execute("SELECT 3")
self.assertEqual(cur.fetchone()[0], 3)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.