Commit ac7f47d7 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

ZMySQLDA: support isolation_level argument in ZMySQLDA.db.query().

parent ce2a342d
...@@ -438,7 +438,7 @@ class DB(TM): ...@@ -438,7 +438,7 @@ class DB(TM):
else: else:
raise raise
def query(self, query_string, max_rows=1000): def query(self, query_string, max_rows=1000, isolation_level=''):
"""Execute 'query_string' and return at most 'max_rows'.""" """Execute 'query_string' and return at most 'max_rows'."""
desc = None desc = None
if isinstance(query_string, six.text_type): if isinstance(query_string, six.text_type):
...@@ -448,8 +448,10 @@ class DB(TM): ...@@ -448,8 +448,10 @@ class DB(TM):
# Unfortunately, MySQLdb does not want to be graceful. # Unfortunately, MySQLdb does not want to be graceful.
if query_string[-1:] == b';': if query_string[-1:] == b';':
query_string = query_string[:-1] query_string = query_string[:-1]
if self._use_TM and not self._registered: if self._use_TM and not self._registered and isolation_level is not None:
if self._isolation_level: if isolation_level:
self._current_isolation_level = isolation_level
elif self._isolation_level:
self._current_isolation_level = self._isolation_level self._current_isolation_level = self._isolation_level
else: else:
for qs in query_string.split(b'\0'): for qs in query_string.split(b'\0'):
...@@ -679,7 +681,7 @@ class DeferredDB(DB): ...@@ -679,7 +681,7 @@ class DeferredDB(DB):
assert self._use_TM assert self._use_TM
self._sql_string_list = [] self._sql_string_list = []
def query(self, query_string, max_rows=1000): def query(self, query_string, max_rows=1000, isolation_level=''):
self._register() self._register()
if isinstance(query_string, six.text_type): if isinstance(query_string, six.text_type):
query_string = query_string.encode('utf-8') query_string = query_string.encode('utf-8')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment