[sqlalchemy] get_schema_names doesn't work with SQLite attached databases
Hi, I'm trying to find the attached databases of a SQLite database. I was expecting Inspector.get_schema_names to return something like: $ sqlite3 foo.db sqlite> create table a (a_id integer); sqlite3 bar.db sqlite> create table b (b_id integer); from sqlalchemy import create_engine from sqlalchemy.inspection import inspect engine = create_engine("sqlite://", echo=True) engine.execute("attach database 'foo.db' as foo") engine.execute("attach database 'bar.db' as bar") refl = inspect(engine) refl.get_table_names(schema="foo") # works refl.get_table_names(schema="bar") # works refl.get_columns("a", schema="foo") # works refl.get_columns("b", schema="bar") # works refl.get_schema_names() # doesn't work, returns [] It doesn't seem the SQLite dialect supports this, but it does seem like the SQLite dialect could support this via the equivalent of this: @reflection.cache def get_schema_names dl = connection.execute("PRAGMA database_list") return [r[1] for r in dl] Is this reasonable? Could it be included in the SQLite dialect? Brian -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
Re: [sqlalchemy] get_schema_names doesn't work with SQLite attached databases
On 9/9/15 4:59 PM, Van Klaveren, Brian N. wrote: Hi, I'm trying to find the attached databases of a SQLite database. I was expecting Inspector.get_schema_names to return something like: $ sqlite3 foo.db sqlite> create table a (a_id integer); sqlite3 bar.db sqlite> create table b (b_id integer); from sqlalchemy import create_engine from sqlalchemy.inspection import inspect engine = create_engine("sqlite://", echo=True) engine.execute("attach database 'foo.db' as foo") engine.execute("attach database 'bar.db' as bar") refl = inspect(engine) refl.get_table_names(schema="foo") # works refl.get_table_names(schema="bar") # works refl.get_columns("a", schema="foo") # works refl.get_columns("b", schema="bar") # works refl.get_schema_names() # doesn't work, returns [] It doesn't seem the SQLite dialect supports this, but it does seem like the SQLite dialect could support this via the equivalent of this: @reflection.cache def get_schema_names dl = connection.execute("PRAGMA database_list") return [r[1] for r in dl] Is this reasonable? Could it be included in the SQLite dialect? sure, send a PR and we can have this in 1.1. Brian -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.