Everything was working fine, but I started to get this error when I run
deal.py:
:\Python27\lib\site-packages\sqlalchemy\ext\declarative.py:1343: SAWarning:
The classname 'Deal' is already in the registry of this declarative base,
mapped to <class 'plexus.cfm.deal.Deal'>
_as_declarative(cls, classname, cls.__dict__)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py",
line 487, in runfile
execfile(filename, namespace)
File "C:\env\plexus\plexus\cfm\deal.py", line 33, in <module>
class Deal(Base):
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative.py", line
1343, in __init__
_as_declarative(cls, classname, cls.__dict__)
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative.py", line
1244, in _as_declarative
**table_kw)
File "C:\Python27\lib\site-packages\sqlalchemy\schema.py", line 305, in
__new__
"existing Table object." % key)
sqlalchemy.exc.InvalidRequestError: Table 'deal' is already defined for
this MetaData instance. Specify 'extend_existing=True' to redefine options
and columns on an existing Table object.
I have two modeles data.py and deal.py. I use data.py to run my queries
and define the declarative_base. There are other models that import it, so
I decided to keep it in a central place.
Here is the start of data.py
from sqlalchemy import create_engine
from zope.sqlalchemy import ZopeTransactionExtension
from sqlalchemy.orm import (
scoped_session,
sessionmaker,
)
from sqlalchemy.ext.declarative import declarative_base
from deal import Deal
and here is Deal.py
from sqlalchemy import (
ForeignKey,
Column,
String,
Integer,
Text,
Date,
Float,
)
from sqlalchemy.orm import (
backref,
relationship,
)
from plexus.cfm.data import Base
class Deal(Base):
# Define class
I really appreciate any help.
Thanks,
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.