Hi all,
I am building some CRUD pages for a Pyramid web app, and encountered some
(from my point of view as a SQLAlchemy novice) strange behaviour. The UI
sends an ID and inside the controller I'd like to delete the corresponding
record. I use SQL expressions inside a session for this. The delete
statement is correctly built and executed, but the record is still in the
database.
A code snippet to test this follows. I have 7 records in the DB, and the
first count says 7. After the delete, the count correctly says 6, but still
the db has 7 records. Even an explicit transaction.commit() does not help.
DbSession =
scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
sess = DbSession()
qry = select([func.count(trm.c.id)])
total = sess.execute(qry).scalar()
print "Total:", total
qdel = trm.delete().where(trm.c.id == 1)
sess.execute(qdel)
total = sess.execute(qry).scalar()
print "Total:", total
transaction.commit()
Hopefully, anybody here can help me out. Thanks in advance.
Dirk
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/SWT9m7mMWk8J.
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.