After running a number of arbitrary SQL statements upon a sqlalchemy
session, I'm finding that when I attempt to commit the transaction,
the changes which are in the session, get lost.  I'm sure I'm missing
something, but not sure what.  Essentially, what I have looks like
this:

import transaction
import sqlahelper
from sqlalchemy import create_engine

engine = create_engine('sqlite:///profiles.db', echo=True)
sqlahelper.add_engine(engine)

statements =  [
    'CREATE TABLE associations (uid TEXT, type TEXT, value TEXT);',
    "INSERT INTO associations VALUES('chuck','department','Nerd
Herd');",
    "INSERT INTO associations VALUES('chuck','company','Buy More');",
]
Session = sqlahelper.get_session()
session = Session()
for statement in statements:
    session.execute(statement)

#session.execute('select * from associations') produces results here
#session.bind.execute('select * from associations') produces no
results here
transaction.commit()
#session.execute('select * from associations') now produces no results


After committing, the table is created, but no entries are present.
If an additional create table statement (eg 'CREATE TABLE fake;') is
added to the end of the list of statements, the `associations` table
has all records correctly. Without this, all preceding INSERT
statements are seemingly 'lost'.

Any ideas on why this is the case and how I can fix this?

Using Sqlalchemy 0.7.4, Python 2.7 and Sqlite.

-- 
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