Hi

I started a pyramid project using the alchemy scaffold (includes ZopeTransactionExtension to scope sessions to requests, see [1]).

Trying to insert many 'shots' into a MySQL database with a single SQL statement, I implemented the following view:

DBSession = scoped_session(
    sessionmaker(extension=ZopeTransactionExtension()))

@view_config(route_name='upload')
def upload_view(request):
    shotlist = []
    shotlist.append(Shot(score=92))
    shotlist.append(Shot(score=82))
    shotlist.append(Shot(score=99))
    shotlist.append(Shot(score=78))

    # The transaction is only committed if this line is enabled:
    # DBSession.add(Shot(score=42))

    DBSession.execute(Shot.__table__.insert(),
                      [shot.__dict__ for shot in shotlist])

    return Response('OK')

But the transaction is not committed. I discovered that the transaction is committed only if I call add() on DBSession (all five shots are inserted then)...

I'm using python 3.3.1 and the following libraries:

- PyMySQL3 0.5
- waitress 0.8.7
- SQLAlchemy 0.8.2
- transaction 1.4.1
- zope.sqlalchemy 0.7.3
- zope.interface 4.0.5
- zope.deprecation 4.0.2
- ...

[1] http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/installation.html#decisions-the-alchemy-scaffold-has-made-for-you

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to