summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/mysql.py
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2007-07-17 13:21:46 +0000
committerJason Kirtland <jek@discorporate.us>2007-07-17 13:21:46 +0000
commit23d01887491c646e321f6bb1e8427b3dd82581c1 (patch)
treed3e0d849c59b9439b4aaa3e72269529339177397 /lib/sqlalchemy/databases/mysql.py
parent6506939352a2a52071bd56fcf5a8af243ec8e27b (diff)
downloadsqlalchemy-23d01887491c646e321f6bb1e8427b3dd82581c1.tar.gz
- Added basic schema reflection coverage to main tests
- Fix stupid mysql typo (#662) - Merged mysql osx/multibyte has_table from 0.4 (r2943)
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r--lib/sqlalchemy/databases/mysql.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 5806bee2e..d656964b1 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -1044,11 +1044,21 @@ class MySQLDialect(ansisql.ANSIDialect):
return self._default_schema_name
def has_table(self, connection, table_name, schema=None):
+ # SHOW TABLE STATUS LIKE and SHOW TABLES LIKE do not function properly
+ # on macosx (and maybe win?) with multibyte table names.
+ #
+ # TODO: if this is not a problem on win, make the strategy swappable
+ # based on platform. DESCRIBE is much slower.
if schema is not None:
- st = 'SHOW TABLE STATUS FROM `%s` LIKE %%s' % schema
+ st = "DESCRIBE `%s`.`%s`" % (schema, table_name)
else:
- st = 'SHOW TABLE STATUS LIKE %s'
- return connection.execute(st, table_name).rowcount != 0
+ st = "DESCRIBE `%s`" % table_name
+ try:
+ return connection.execute(st).rowcount > 0
+ except exceptions.SQLError, e:
+ if e.orig.args[0] == 1146:
+ return False
+ raise
def get_version_info(self, connectable):
if hasattr(connectable, 'connect'):
@@ -1160,7 +1170,7 @@ class MySQLDialect(ansisql.ANSIDialect):
def _escape_table_name(self, table):
if table.schema is not None:
- return '`%s`.`%s`' % (table.schema. table.name)
+ return '`%s`.`%s`' % (table.schema, table.name)
else:
return '`%s`' % table.name