On Feb 19, 2009, at 6:42 PM, Jeff Cook wrote:
>
> Using the following code with Pylons, SQLAlchemy and SQLSoup:
>
> def add(self):
> ians = text (""" SELECT * FROM insert_clinic(:name, :addr,
> :city, :state, :zip, :taxid, :note, :website, :addedby) """)
> conn = meta.soup.engine.connect()
> ins = conn.execute(ians, name=request.params['name'],
> addr=request.params['address'], city=request.params['city'],
> state=request.params['state'], zip=request.params['zip'],
> taxid=request.params['taxid'], note=request.params['note'],
> website=request.params['website'], addedby=session['user_id'])
> Session.commit()
the engine.connect() returns a connection that is autocommitting. The
Session.commit() is unrelated and will have no effect here since you
are not making usage of the Session's execute() method. If you see
ROLLBACK in your logs, thats because ROLLBACK is issued when
connections are returned to the pool so that locks and transactional
state are released.
Above, you're only executing a "SELECT" statement, so no autocommit
will occur. If the insert_clinic() requires commit, here are your
three options:
1. send it as text("select * from ...", autocommit=True).
2. use Session.execute(), so that the Session.commit() is meaningful
3. create a transaction on your connection; trans = conn.begin();
conn.execute(...); trans.commit().
You're likely looking for #2 here.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---