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/sqlite.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/sqlalchemy/databases/sqlite.py') diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index f074d02fa..b2aeb75fd 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -158,11 +158,13 @@ class SQLiteDialect(ansisql.ANSIDialect): def reflecttable(self, connection, table): c = connection.execute("PRAGMA table_info(" + table.name + ")", {}) + found_table = False while True: row = c.fetchone() if row is None: break #print "row! " + repr(row) + found_table = True (name, type, nullable, primary_key) = (row[1], row[2].upper(), not row[3], row[5]) match = re.match(r'(\w+)(\(.*?\))?', type) @@ -176,6 +178,10 @@ class SQLiteDialect(ansisql.ANSIDialect): #print "args! " +repr(args) coltype = coltype(*[int(a) for a in args]) table.append_item(schema.Column(name, coltype, primary_key = primary_key, nullable = nullable)) + + if not found_table: + raise exceptions.NoSuchTableError(table.name) + c = connection.execute("PRAGMA foreign_key_list(" + table.name + ")", {}) while True: row = c.fetchone() -- cgit v1.2.1