6

I suddenly started seeing an error in my Python SQLAlchemy application and I can't figure out what's causing it. My code looks like this:

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)

And when I run this script I get the following error:

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

I am using SQLAlchemy 0.9.1. My backend is MySQL running on the localhost. As far as I can tell by inspecting with pdb connection, session, Base, Column, and Integer all seem normal.

1
  • 2
    According to docs, Integer takes no arguments. Commented Jan 16, 2014 at 3:47

1 Answer 1

8

Integer takes no parameters. This is a change in version 0.9.

There exist BigInteger and SmallInteger instead.

Sign up to request clarification or add additional context in comments.

3 Comments

Note that it took arguments in 0.8 version: docs.
^^^ @alecxe AH-HA! I had to rebuild my python environment this week. I bet that upgraded me from 0.8 to 0.9 without me noticing!
@ACV, yeah, that's why it's better to freeze project requirements with precise package versions - who knows what is going to change in your dependencies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.