When reflecting a MSSQL table with a foreign key, the referenced table
fails to load with the error:
sqlalchemy.exc.NoSuchTableError: [referenced_table]
For this case, I'm using:
SA 0.5 RC2
Python 2.5
UnixODBC 2.2.11
tdsodbc 0.63-3.2
The test case uses schema names. Reflection will work with t1, but not
with t2 I assume because of the foreign keys. I tried this also without
schemas and it wouldn't reflect either table.
# test code
import sqlalchemy as sa
engine = sa.create_engine('mssql://somebody:[EMAIL PROTECTED]/test')
t1_query = "create table somebody.t1 (id int primary key, name char(10))"
t2_query = """
create table somebody.t2 (id int primary key, name char(10),
t1_id int references somebody.t1(id))
"""
engine.execute(t1_query)
engine.execute(t2_query)
try:
meta = sa.MetaData(bind=engine)
##t1 = sa.Table('t1', meta, schema='somebody', autoload=True)
##print t1.columns.keys()
t2 = sa.Table('t2', meta, schema='somebody', autoload=True)
print t2
finally:
engine.execute('drop table somebody.t2')
engine.execute('drop table somebody.t1')
Fails with:
sqlalchemy.exc.NoSuchTableError: t1
--Randall
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---