Hello everybody,
I am writing a component of an application that should display a chart of
database tables and foreign keys (this one
<https://github.com/mara/mara-db/tree/schema-ui-engine-agnostic>), and
trying to make it database agnostic. I encountered a strange behavior when
inspecting the foreign keys of a SQLite database, in particular I can't see
them by setting schema_name to the value returned from get_schema_names but
only by passing schema_name=None.
I create a test db this way:
conn = sqlite3.connect('test.db')
conn.execute('CREATE TABLE table_one(column_one INTEGER, column_two TEXT)')
conn.execute("""CREATE TABLE table_two(
column_X INTEGER,
column_Y TEXT,
FOREIGN KEY(column_X) REFERENCES table_one(column_one)
)""")
conn.close()
If I use a sqlite database I see that
inspect(engine).get_schema_names()
returns *['main']* and
sa.engine.reflection.Inspector.from_engine(db).get_table_names('main')
shows the tables in the database, as expected.
But when I run
sa.engine.reflection.Inspector.from_engine(db).get_foreign_keys('table_name',
schema='main')
it doesn't return any foreign key, while it does with *schema=None*
is this a bug or the expected behavior?
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.