system views not reflectable via metadata.reflect(only=['sqlite_master'])
Issue #950
resolved
The special sqlite_master metadata table is not reflectable via sqlalchemy.
Try:
import sqlalchemy
from sqlalchemy import Table, Column, MetaData, Integer
conn = sqlalchemy.create_engine('sqlite:///:memory:')
meta = MetaData()
meta.bind = conn
t = sqlalchemy.Table('test',meta,Column('a',Integer))
t.create()
meta.reflect(only=['sqlite_master']('sqlite_master'))
Basically the table is not listed itself in sqlite_master, but is in principle introspectable. The sqlite driver should maybe add sqlite_master to the list of available tables. Or one could argue thats more a view and that it isn't introspectable per se.
Comments (3)
-
-
repo owner - changed milestone to blue sky
-
repo owner - changed status to wontfix
no action is going to be taken here as metadata.reflect_all() is about the user-defined tables.
- Log in to comment
The system views are reflectable if named explicitly:
They aren't reflected in the table name list though. I think most of the dialects omit system-owned views from the tables list, and I'll put a stick in the ground and say that sqlite should continue to as well, at least for now.
metadata.drop_all()
shouldn't try to dropsqlite_master
, which is what would happen today ifmetadata.reflect()
pulled that in as well. Future work on view reflection could eliminate that hiccup.Allowing
only=['sqlite_master']('sqlite_master')
to load an identifier that's not present in the full list or available to the callable variant ofonly
wigs me out a little... It would be more convenient than the explicit alternative, though.Poking into this revealed that we weren't considering temporary tables with reflect(), and that's now in 5320a47a14177e48a993e5333851888252a2d691 along with improved handling of sqlite_master on attached databases.