Permalink
Browse files

Finishing support for Postgres.

  • Loading branch information...
1 parent 527d521 commit 694d47620db4b97d38030fef866be5c1d723819c @mrjbq7 mrjbq7 committed Jun 10, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 tracsql/web_ui.py
View
@@ -205,6 +205,8 @@ def _process_schema(self, req, cursor, data):
sql = 'show tables'
elif self.db_type == 'sqlite':
sql = 'SELECT name FROM sqlite_master WHERE type = "table"'
+ elif self.db_type == 'postgres':
+ sql = "select table_name from information_schema.tables where table_schema = 'public'"
else:
assert False, "Unsupported db_type: %s" % self.db_type
@@ -227,6 +229,18 @@ def _process_schema(self, req, cursor, data):
sql = 'describe %s' % table
elif self.db_type == 'sqlite':
sql = 'PRAGMA table_info("%s")' % table
+ elif self.db_type == 'postgres':
+ sql = """
+ select
+ ordinal_position,
+ column_name,
+ data_type,
+ is_nullable,
+ column_default
+ from information_schema.columns
+ where table_schema = 'public' and
+ table_name = '%s'
+ """ % table
else:
assert False, "Unsupported db_type: %s" % self.db_type

0 comments on commit 694d476

Please sign in to comment.