Don Dwiggins
2008-02-23 02:06:18 UTC
I'm running SA 0.4.3 on Win XP, accessing a MSSQL database using pyodbc,
and I want to autoload some table definitions. In the Metadata
documentation, I read:
"Note that if a reflected table has a foreign key referencing another
table, the related Table object will be automatically created within the
MetaData object if it does not exist already."
This doesn't seem to work. When I reflect a table with FKs, it comes in
OK, and the metadata seems to know about the FK, but eval'ing
'referenced_table' in meta.tables
(as in the example) returns False.
Also, reflecting the referenced table without the autoload=True
parameter doesn't work -- the table I get is empty (but it does come in
OK if I use autoload).
I also tried using meta.table_iterator, and got a message like "Could
not find table xxx with which to generate a foreign key". The table its
asking for is indeed referenced, and if I autoload it (and all the other
referenced tables), the iterator works fine.
I can understand that it might not be a good idea, when autoloading a
table, to try to bring in the entire "FK tree" with it; in my database,
doing that on some tables would bring in several dozen other tables.
I'm really just trying to reconcile what I read in the docs with how the
code works.
Thanks for any good words,
--
Don Dwiggins
Advanced Publishing Technology
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---
and I want to autoload some table definitions. In the Metadata
documentation, I read:
"Note that if a reflected table has a foreign key referencing another
table, the related Table object will be automatically created within the
MetaData object if it does not exist already."
This doesn't seem to work. When I reflect a table with FKs, it comes in
OK, and the metadata seems to know about the FK, but eval'ing
'referenced_table' in meta.tables
(as in the example) returns False.
Also, reflecting the referenced table without the autoload=True
parameter doesn't work -- the table I get is empty (but it does come in
OK if I use autoload).
I also tried using meta.table_iterator, and got a message like "Could
not find table xxx with which to generate a foreign key". The table its
asking for is indeed referenced, and if I autoload it (and all the other
referenced tables), the iterator works fine.
I can understand that it might not be a good idea, when autoloading a
table, to try to bring in the entire "FK tree" with it; in my database,
doing that on some tables would bring in several dozen other tables.
I'm really just trying to reconcile what I read in the docs with how the
code works.
Thanks for any good words,
--
Don Dwiggins
Advanced Publishing Technology
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---