summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/mysql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-06-06 00:11:54 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-06-06 00:11:54 +0000
commitbdb41655d14caed41e93225f79e5554925a15e20 (patch)
tree7e7ecf0d0dfb59b14bc34f77c5ae29e37f9f1755 /lib/sqlalchemy/databases/mysql.py
parente69fa9c45d77b2c27311d54155c78ee44ce551f9 (diff)
downloadsqlalchemy-bdb41655d14caed41e93225f79e5554925a15e20.tar.gz
added "NonExistentTable" exception throw to reflection, courtesy lbruno@republico.estv.ipv.pt, for [ticket:138]
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r--lib/sqlalchemy/databases/mysql.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 0a480ec11..aa05134d0 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -182,15 +182,18 @@ class MySQLDialect(ansisql.ANSIDialect):
# to use information_schema:
#ischema.reflecttable(self, table, ischema_names, use_mysql=True)
- tabletype, foreignkeyD = self.moretableinfo(connection, table=table)
- table.kwargs['mysql_engine'] = tabletype
-
c = connection.execute("describe " + table.name, {})
+ found_table = False
while True:
row = c.fetchone()
if row is None:
break
#print "row! " + repr(row)
+ if not found_table:
+ tabletype, foreignkeyD = self.moretableinfo(connection, table=table)
+ table.kwargs['mysql_engine'] = tabletype
+ found_table = True
+
(name, type, nullable, primary_key, default) = (row[0], row[1], row[2] == 'YES', row[3] == 'PRI', row[4])
match = re.match(r'(\w+)(\(.*?\))?', type)
@@ -214,6 +217,8 @@ class MySQLDialect(ansisql.ANSIDialect):
nullable=nullable,
default=default
)))
+ if not found_table:
+ raise exceptions.NoSuchTableError(table.name)
def moretableinfo(self, connection, table):
"""Return (tabletype, {colname:foreignkey,...})
@@ -286,4 +291,4 @@ class MySQLSchemaDropper(ansisql.ANSISchemaDropper):
self.append("\nDROP INDEX " + index.name + " ON " + index.table.name)
self.execute()
-dialect = MySQLDialect \ No newline at end of file
+dialect = MySQLDialect