sqlite - Questions about create table and transaction in sqlite3 of python -


i'm learning use sqlite in python sqlite3.

the sql operations insert, update support support transaction , commit() should called before close connection, or nothing change in database. however, 'create table' not support transaction, or create table auto committed. example,

con.execute('create table xxx (xxxx)') 

the table created instantly. what's more, if execute insert statement before creating table, without commit(). execute create table, insert committed, 'create table'.

i found nothing mentioned such behavior in document https://docs.python.org/2/library/sqlite3.html#sqlite3-types ,https://www.python.org/dev/peps/pep-0249/#id3 or https://sqlite.org/atomiccommit.html.

my question is: 1. there other operations behave this? 2. other dbms behave? 3. there specification this?

this behaviour comes neither sqlite (commands create table work inside transactions) nor python; it's python sqlite3 module tries clever , inserts automatic transactions @ places.

this documented, reasons given rather flimsy:

there 2 reasons doing that. first of these commands don’t work within transactions.

if module wouldn't automatically start transactions, not required close them before commands.

the other reason sqlite3 needs keep track of transaction state (if transaction active or not).

if module wouldn't automatically start transaction, not need keep track of transaction state

please note detection of dml statements not work correctly in cases.

i'd recommend disable craziness clearing isolation_level.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -