When an autoload of a non-existing table fails:

>>> from sqlalchemy import *
>>> md = BoundMetaData('sqlite:///test.db')
>>> Table('nonesuch', md, autoload=True)
Traceback (most recent call last):
...
sqlalchemy.exceptions.NoSuchTableError: nonesuch


the table remains in the metadata dict:


>>> md.tables
{'nonesuch': Table('nonesuch',
BoundMetaData(),
schema=None)}


that way, a subsequent definition of the same table fails:


>>> Table('nonesuch', md,
...     Column('id', Integer, primary_key=True))
Traceback (most recent call last):
...
sqlalchemy.exceptions.ArgumentError: Table 'None.nonesuch' is already
defined. specify 'redefine=True' to remap columns, or 'useexisting=True'
to use the existing table


One could use the 'redefine=True' parameter to avoid this error, but
I would prefer avoiding it, because in some cases that would actually,
and wrongly, redefine a table.

The patch attached to ticket #289 deregisters the table, but only when
autoloading raises NoSuchTableError, and therefore makes the subsequent
definition work.


-- 
Nicola Larosa - http://www.tekNico.net/

Fear is the prison, its absence is the key. What we need is the under-
standing and the will to change the reality that manifests as control
and suppression, and this can never be done while we are imprisoned by
fear. Freedom from fear is freedom itself. -- David Icke, March 2006



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to