Michael Bayer wrote: > theres not, but if someone wants to submit a patch that works for all > the db engines (or most of them), id commit it.
i'd say I already sent this patch yesterday but I don't see it show up, so here again. I'm using the following function, that works for sqlite, postgresql and mysql: def list_tables(eng=None, schema=None): if not eng: eng = schema.default_metadata.engine if eng.name == 'sqlite': sql = """ SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;""" elif eng.name == 'postgres': if schema == None: schema_constraint = '' else: schema_constraint = "AND n.nspname = :schema" sql = """ SELECT c.relname as name, n.nspname as schema,c.relkind, u.usename as owner FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN ('r') %s AND pg_catalog.pg_table_is_visible(c.oid) ORDER BY 1,2; """ % (schema_constraint) # sequences and views can be fount in postgres just changind this: # c.relkind IN ('r') 'v','S' elif eng.name in ( 'mysql'): sql = "SHOW TABLES" ret = eng.text(sql).execute(schema=schema) tables = [R[0] for R in ret] return tables Mike, I already sent it early july, maybe you would prefer to split it into different dialects to get rid of the ifs?... sandro *:-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---