pgtoolkit/pgbrowser.py
changeset 68 b0d972be2631
parent 59 65efd0c6919f
child 85 11a282e23e0d
equal deleted inserted replaced
67:78478a49c0bd 68:b0d972be2631
    64         self.valid = valid
    64         self.valid = valid
    65         self.definition = definition
    65         self.definition = definition
    66 
    66 
    67 
    67 
    68 class Table:
    68 class Table:
    69     def __init__(self, browser, schema, name, owner, size, description):
    69     def __init__(self, browser, schema, name, owner, size, description, options):
    70         self._columns = None
    70         self._columns = None
    71         self._constraints = None
    71         self._constraints = None
    72         self._indexes = None
    72         self._indexes = None
    73         self.browser = browser  # Browser instance
    73         self.browser = browser  # Browser instance
    74         self.schema = schema  # Schema instance
    74         self.schema = schema  # Schema instance
    75         self.name = name  # table name, str
    75         self.name = name  # table name, str
    76         self.owner = owner
    76         self.owner = owner
    77         self.size = size
    77         self.size = size
    78         self.description = description
    78         self.description = description
       
    79         self.options = options or []
    79 
    80 
    80     def refresh(self):
    81     def refresh(self):
    81         self.refresh_columns()
    82         self.refresh_columns()
    82         self.refresh_constraints()
    83         self.refresh_constraints()
    83         self.refresh_indexes()
    84         self.refresh_indexes()
   267         return self._query('''
   268         return self._query('''
   268             SELECT
   269             SELECT
   269                 c.relname as "name",
   270                 c.relname as "name",
   270                 pg_catalog.pg_get_userbyid(c.relowner) as "owner",
   271                 pg_catalog.pg_get_userbyid(c.relowner) as "owner",
   271                 pg_catalog.pg_relation_size(c.oid) as "size",
   272                 pg_catalog.pg_relation_size(c.oid) as "size",
   272                 pg_catalog.obj_description(c.oid, 'pg_class') as "description"
   273                 pg_catalog.obj_description(c.oid, 'pg_class') as "description",
       
   274                 c.reloptions as "options"
   273             FROM pg_catalog.pg_class c
   275             FROM pg_catalog.pg_class c
   274             LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
   276             LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
   275             WHERE n.nspname = %s AND c.relkind IN ('r','s','')
   277             WHERE n.nspname = %s AND c.relkind IN ('r','s','')
   276             ORDER BY 1;
   278             ORDER BY 1;
   277             ''', [schema])
   279             ''', [schema])