diff -r 0cef3540b69f -r 922d7fb63384 pgtoolkit/pgbrowser.py --- a/pgtoolkit/pgbrowser.py Mon Jul 09 10:29:47 2012 +0200 +++ b/pgtoolkit/pgbrowser.py Fri Aug 17 11:07:22 2012 +0200 @@ -42,11 +42,13 @@ class Constraint: - def __init__(self, browser, table, name, type, definition): + def __init__(self, browser, table, name, type, fname, fschema, definition): self.browser = browser self.table = table self.name = name self.type = type + self.fname = fname # foreign table name + self.fschema = fschema # foreign table schema self.definition = definition @@ -211,7 +213,7 @@ def list_columns(self, table, schema='public', order=2): return self._query(''' SELECT - a.attrelid, + --a.attrelid, a.attname as "name", format_type(a.atttypid, a.atttypmod) AS "type", a.attnotnull as "notnull", @@ -261,6 +263,24 @@ ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname ''', {'schema': schema, 'table': table}) + def list_sequences(self, schema=None): + '''List sequences in schema.''' + return self._query(''' + SELECT + nc.nspname AS "sequence_schema", + c.relname AS "sequence_name", + t.relname AS "related_table", + a.attname AS "related_column", + format_type(a.atttypid, a.atttypmod) AS "related_column_type" + FROM pg_class c + JOIN pg_namespace nc ON nc.oid = c.relnamespace + JOIN pg_depend d ON d.objid = c.oid + JOIN pg_class t ON d.refobjid = t.oid + JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum) + WHERE c.relkind = 'S' AND NOT pg_is_other_temp_schema(nc.oid) + ''' + (schema and ' AND nc.nspname = %(schema)s' or '') + ''' + ''', {'schema': schema}) + def list_column_usage(self, table, column, schema='public'): '''List objects using the column.