On Jan 17, 2012, at 10:16 PM, David Beitey wrote:

> 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


This seems like a Pyramid issue since "transaction" / sqlahelper are part of 
the Pyramid thing.   session.commit() would commit the transaction normally so 
you'd want to check that all the pyramid elements are hooked up correctly.


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

the CREATE TABLE may be triggering an autocommit within the pysqlite driver.

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