I'm not sure what I'm doing wrong here to warrant this message. Any help with my configuration would be appreciated.
"""The application's model objects"""
import sqlalchemy as sa
from sqlalchemy import orm
from project.model import meta
def now():
return datetime.datetime.now()
def init_model(engine):
"""Call me before using any of the tables or classes in the model"""
sm = orm.sessionmaker(autoflush=True, autocommit=True, bind=engine)
meta.Session.configure(bind=engine)
meta.engine = engine
meta.Session = orm.scoped_session(sm)
class User(object):
pass
t_user = sa.Table("User", meta.metadata,
sa.Column("id", sa.types.Integer, primary_key=True),
sa.Column("name", sa.types.String(100), nullable=False),
sa.Column("first_name", sa.types.String(100), nullable=False),
sa.Column("last_name", sa.types.String(100), nullable=False),
sa.Column("email", sa.types.String(100), nullable=False),
sa.Column("password", sa.types.String(32), nullable=False)
)
orm.mapper(User,t_user)
From the python console, I am executing:
from project.model import *
mr_jones = User()
meta.Session.add(mr_jones)
mr_jones.name = 'JR Jones'
meta.Session.commit()
And the error I receive is:
sqlalchemy.exc.UnboundExecutionError: Could not locate a bind configured on mapper Mapper|User|User or this Session
Thanks for your help.