From bdb41655d14caed41e93225f79e5554925a15e20 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 6 Jun 2006 00:11:54 +0000 Subject: added "NonExistentTable" exception throw to reflection, courtesy lbruno@republico.estv.ipv.pt, for [ticket:138] --- lib/sqlalchemy/databases/mysql.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/databases/mysql.py') 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 -- cgit v1.2.1