Hi all,
i have a legacy system which provides some special database views to provide
schema information for an application in a database independent way
(and with some quirks).
Now i need to port this to sqlalchemy and want to use it as one source of
schema information instead of the default SQLAlchemy reflection. That works
fine,
i just added a derived Metadata class that does reflection via my legacy schema
information system.
BUT, as this is legacy stuff it misses out on some of the nicer features of
SQLAlchemy
and modern databases like Foreign Keys, Constraints, Defaults and all that
stuff.
The legacy app has some of that information available in various layers, so i
need to
merge that info into my Metadata, e.g. to add ForeignKeys that are not modelled
in the database
layer and all that legacy stuff.
So my basic approach was something like:
# get the table information from the legacy schema info system
meta = db.MyMeta.reflect(only=[...])
Now i have a bunch of Table objects inside the Metadata with my custom datatypes
correctly set and all that, but don't have any foreign key stuff yet.
Is there any good way to merge extra Constraints and Defaults and ForeignKeys
into
an already defined Table object?
My naive approach failed:
>>> fk =
>>> ForeignKeyConstraint(['initial_manager'],['angestellter.personalnummer'])
>>> proj = Table('project',db.meta,fk)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"c:\sdk\win32\1.0\Python25\lib\site-packages\sqlalchemy-0.4.1-py2.5.egg\s
qlalchemy\schema.py", line 103, in __call__
raise exceptions.ArgumentError("Table '%s' is already defined for this
MetaD
ata instance." % key)
sqlalchemy.exceptions.ArgumentError: Table 'project' is already defined for this
MetaData instance.
Michael
--
Michael Schlenker
Software Engineer
CONTACT Software GmbH Tel.: +49 (421) 20153-80
Wiener Straße 1-3 Fax: +49 (421) 20153-41
28359 Bremen
http://www.contact.de/ E-Mail: [EMAIL PROTECTED]
Sitz der Gesellschaft: Bremen | Geschäftsführer: Karl Heinz Zachries
Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---