summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/mysql.py
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2007-08-12 22:05:30 +0000
committerJason Kirtland <jek@discorporate.us>2007-08-12 22:05:30 +0000
commit872a882d0d93da79797a0cde70cbb2379f2e42d8 (patch)
tree23b1932f4731924c35ac96c0668ee2842651df18 /lib/sqlalchemy/databases/mysql.py
parent6e477b750eb432e91f933abae3aff3cb58b27362 (diff)
downloadsqlalchemy-872a882d0d93da79797a0cde70cbb2379f2e42d8.tar.gz
auto-commit after LOAD DATA INFILE for mysql
caught a couple more uncompiled regexps
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r--lib/sqlalchemy/databases/mysql.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 5aebac09b..6f8b83189 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -183,6 +183,12 @@ RESERVED_WORDS = util.Set(
'read_only', 'read_write', # 5.1
])
+AUTOCOMMIT_RE = re.compile(
+ r'\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|LOAD +DATA)',
+ re.I | re.UNICODE)
+SELECT_RE = re.compile(
+ r'\s*(?:SELECT|SHOW|DESCRIBE|XA RECOVER)',
+ re.I | re.UNICODE)
class _NumericType(object):
"""Base for MySQL numeric types."""
@@ -1274,7 +1280,7 @@ def descriptor():
class MySQLExecutionContext(default.DefaultExecutionContext):
- _my_is_select = re.compile(r'\s*(?:SELECT|SHOW|DESCRIBE|XA RECOVER)',
+ _my_is_select = re.compile(r'\s*(?:SELECT|SHOW|DESCRIBE|XA +RECOVER)',
re.I | re.UNICODE)
def post_exec(self):
@@ -1285,7 +1291,10 @@ class MySQLExecutionContext(default.DefaultExecutionContext):
self._last_inserted_ids[1:])
def is_select(self):
- return self._my_is_select.match(self.statement) is not None
+ return SELECT_RE.match(self.statement)
+
+ def should_autocommit(self):
+ return AUTOCOMMIT_RE.match(self.statement)
class MySQLDialect(ansisql.ANSIDialect):