Sorry, I'd meant for that code to be self-contained but of course I forgot to 
set up the engine.  As an example you can try the following (see inserted code 
below).

Lance

On 4/23/2010 9:50 AM, jose soares wrote:
session.commit() raises an UnBoundExecutionError:

Would this (not) work?

from sqlalchemy import *
from sqlalchemy.orm import mapper

engine = create_engine('sqlite:///:memory:')

metadata = MetaData()
groups = Table('groups', metadata, Column('id', Integer,
primary_key=True), Column('name', String(25)))

metadata.create(bind=engine)

class Group(object):
pass

mapper(Group, groups)

from sqlalchemy.orm import sessionmaker
Session = sessionmaker()

session = Session()

session.bind = engine

group = Group()
group.name = 'cat'
session.add(group)
session.commit()
UnboundExecutionError: Could not locate a bind configured on mapper
Mapper|Group|groups or this Session

session.expunge_all()
group = session.query(Group).first()
print group.id
session.close()

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to