I have this code:
------------------------------------
from sqlalchemy import *
metadata = MetaData()
storia = Table('storia', metadata,
Column(u'id', Integer, primary_key=True),
Column(u'autore_id', Integer),
Column(u'titolo', String),
schema='public'
)
storia_capitoli = Table('storia_capitoli', metadata,
Column(u'id', Integer, primary_key=True),
Column(u'storia_id', Integer),
Column(u'file', String),
Column(u'directory', String),
Column(u'stato', Integer),
Column(u'data_aggiornamento', Date),
ForeignKeyConstraint(['storia_id'], ['storia.id']),
schema='public'
)
class StoriaCapitoli(object):
def __init__(self, table):
super(StoriaCapitoli, self).__init__()
self.dataset = []
self.headers = ['ID', 'Storia', 'File', 'Directory',
'Stato', 'Data agg.']
self.table = table
for foreign_key in self.table.foreign_keys:
print foreign_key.parent # it works
print select([storia]).execute().fetchone() # it works
print foreign_key.column # it doesn't work
if __name__ == "__main__":
engine = create_engine("postgres://postgres:postg...@localhost:
5432/simone",
encoding = 'utf-8', convert_unicode=True)
metadata.bind = engine
s = StoriaCapitoli(storia_capitoli)
---------------------------------
The last print statement return that error:
sqlalchemy.exc.NoReferencedTableError: Could not find table 'storia'
with which
to generate a foreign key
The select of the table "storia" works fine, but it can't recognize
the table "storia" for the foreign key.
SqlAlchemy 0.5.2, Python 2.6.2 on WinXp.
Is there someone that could tell me why that happens? :)
Thanks,
Simone
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---