I'm using sqlalchemy with sql server express.  Client-side
is also Windows, running python 2.5.2.

I find that all my changes get rolled back when using
0.5.2.  But using 0.4.8, things work as I expect.

Here is an example script:

--- start script ---
import datetime
import sqlalchemy
from sqlalchemy.orm import scoped_session, sessionmaker

print "sqlalchemy version:", sqlalchemy.__version__

conn_str = 'mssql://<user>:<password>@<server>/<database>?dsn=<dsn>'
mssql_engine = sqlalchemy.create_engine(conn_str)
mssql_metadata = sqlalchemy.MetaData(bind=mssql_engine)
MSSQLSession = scoped_session(sessionmaker(bind=mssql_metadata.bind))

data = 'bingo'
now = datetime.datetime.now()
time = now.strftime('%Y-%m-%d %H:%M:%S')
command = "INSERT sa_test (data, time) VALUES ('%s', '%s')" % (data,
time)

session = MSSQLSession()
session.execute(command)
session.commit()

command = "SELECT COUNT(*) FROM sa_test WHERE data='%s'" % data

session = MSSQLSession()
print "count:", session.execute(command).scalar()

MSSQLSession.remove()
--- end script ---

Running this I'll get "count: 1" (assuming a clean sa_test table),
showing
that the insert occurred.  But then looking in the database, I'll see
that
the data aren't there (with 0.5.2; with 0.4.8 the data will be there).

The same thing happens with updates.

It appears to me that the session.commit() call isn't working
with 0.5.2.  I think the transaction is staying open until the call
to MSSQLSession.remove(), which rolls everything back.

Some evidence of that ... If I add the line

raw_input("Enter to exit.")

before the MSSQLSession.remove(), and then while paused there
I go to a query window in sql server express, if I'm using 0.5.2 I'll
find that queries against the table hang -- presumably waiting for
the transaction to finish.  But with 0.4.8 this has no effect -- the
changes have already been committed.

Thanks for any help resolving this.

David

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

Reply via email to