Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why don't DDL statements open a transaction? #105

Closed
aaugustin opened this issue Sep 7, 2016 · 3 comments
Closed

Why don't DDL statements open a transaction? #105

aaugustin opened this issue Sep 7, 2016 · 3 comments

Comments

@aaugustin
Copy link

aaugustin commented Sep 7, 2016

796b3af "introduces" a special case for DDL statements: unlike other statements, they won't open a transaction implicitly when autocommit is off.

("introduces" because it actually adjusts changes from the previous commit...)

The most convenient way to start a database transaction with Python DB-API modules is to turn autocommit off. This commit makes it necessary to special case SQLite by using a BEGIN statement instead of turning autocommit off.

Django currently does this for other reasons (to work around #24, which has been fixed and should make it into Python 3.6). See https://github.com/django/django/blob/271581df606b307d89c141e8b1a50ace763bea81/django/db/backends/base/base.py#L375-L404

I'd love to remove this hack in the long term, but if pysqlite / sqlite3 don't open a transaction consistently when autocommit is off, we'll have to keep it.

In my opinion the least surprising behavior is:

I understand that any documented behavior can be worked around, but it would be so nice if we could keep things simple...

@ghost
Copy link

ghost commented Jan 25, 2017

There is a bug about 796b3af, please see http://bugs.python.org/issue28518
Although it's sqlite3 module, pysqlite should has the same problem.

@ghaering
Copy link
Owner

ghaering commented Aug 7, 2018

It's hard to change anything at this point because of backwards compatibility reasons.

@aaugustin
Copy link
Author

That was the answer I expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants