On Feb 25, 2008, at 9:03 PM, Tim Lesher wrote:
I'm using SQLAlchemy, reflecting from an existing MySQL database. I
want to override two DateTime columns to provide proper created and
updated timestamps (since MySQL can't handle auto-updating two
TIMESTAMP columns in the same row).
According to the SA docs, this should work; however, when I autoload
my Table objects, I get the error:
class 'sqlalchemy.exceptions.ArgumentError': Table 'tablename' is
already defined for this MetaData instance.
This short example illustrates the issue; the test_users table fails
to load. The error goes away if I either remove the foreign key
constraints in the 'test_pets' table, or remove the Column overrides
from the 'test_users' table.
It seems as if SA is instantiating the users mapper first (because the
pets table refers to it), but not paying attention to the override; it
then tries to instantiate the users mapper to effect the override, but
fails.
Thanks in advance...
upgrade to 0.4.3. The error message is now Table '%s' is already
defined for this MetaData instance. Specify 'useexisting=True' to
redefine options and columns on an existing Table object.. This new
behavior allows the useexisting=True flag, which has been around for a
long time, to use an existing table and overrride the columns, i.e.:
t1 = Table('users', meta, autoload=True)
t2 = Table('addresses', meta, Column('id', Integer, primary_key=True),
autoload=True, useexisting=True)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~--~~~~--~~--~--~---