flask-sqlalchemy icon indicating copy to clipboard operation
flask-sqlalchemy copied to clipboard

db.create_all shouldn't trigger intermediate commits

Open jeffwidman opened this issue 9 years ago • 2 comments

I can't figure out how to call db.create_all() without triggering intermediate commits after each table is created: http://stackoverflow.com/questions/34410091/flask-sqlalchemy-how-can-i-call-db-create-all-and-db-drop-all-without-trigg

Pretty sure vanilla SQLAlchemy doesn't have them in db.metadata.create_all.

I'm not sure which part of this library is actually triggering the commits, but I can't think of a reason they need to be there... the commits are causing problems for me because for some tests, I'd like to create some PostgreSQL tables within the same transaction, and then drop the transaction without committing.

If anyone has any idea what the root cause of the intermediate commits is, I'm happy to take a stab at fixing it.

jeffwidman avatar Jan 12 '16 08:01 jeffwidman

Seems like you got answer for this in stackoverflow? The behavior cannot be changed in flask-sqlalchemy.

kblomqvist avatar May 01 '16 15:05 kblomqvist

No, the SO answer indicates that for PostgreSQL this may be possible, and it's only for MySQL that this isn't possible due to MySQL's lack of transactional support for DDL.

jeffwidman avatar May 02 '16 06:05 jeffwidman

This is a behavior of SQLAlchemy, it's not something we should address.

davidism avatar Sep 18 '22 17:09 davidism