我突然开始在我的Python SQLAlchemy应用程序中看到一个错误,我无法弄清楚导致它的原因.我的代码看起来像这样:
from sqlalchemy import create_engine
from sqlalchemy import Column
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import MetaData
from sqlalchemy.ext.declarative import declarative_base
def loadConnection(connection_string, echo=False):
engine = create_engine(connection_string, echo=echo)
Base = declarative_base(engine)
Session = sessionmaker(bind=engine)
session = Session()
return session, Base
connection = yaml.load('connection.yaml')
session, Base = loadConnection(connection['connection'], connection['echo'])
class Foo(Base):
__tablename__ = 'foo'
id = Column(Integer(11), primary_key=True)
Run Code Online (Sandbox Code Playgroud)
当我运行此脚本时,我收到以下错误:
Traceback (most recent call last):
File "ephem/database_interface.py", line 52, in <module>
class Foo(Base):
File "ephem/database_interface.py", line 54, in Foo
id = Column(Integer(11), primary_key=True)
TypeError: object() takes no parameters
Run Code Online (Sandbox Code Playgroud)
我正在使用SQLAlchemy 0.9.1.我的后端是在localhost上运行的MySQL.至于我可以用PDB检查告知connection,session,Base,Column,和Integer都显得正常.
Integer没有参数.这是0.9版本的更改.
存在BigInteger而SmallInteger不是.
| 归档时间: |
|
| 查看次数: |
2314 次 |
| 最近记录: |