Re: [sqlite] What is the default value of isolation_level?
On Friday, 25 October, 2019 13:49, Peng Yu wrote: >isolation_level is an empty string by default as shown below. But the >python manual does not say that it can take an empty string. What does >an empty string mean? Is it equivalent to None? Thanks. No. It means use the default. And sqlite3 defaults to using deferred transactions, so '' is equivalent to 'deferred'. >https://docs.python.org/3/library/sqlite3.html#connection-objects >""" >isolation_level >Get or set the current default isolation level. None for >autocommit mode or one of “DEFERRED”, “IMMEDIATE” or “EXCLUSIVE”. See >section Controlling Transactions for a more detailed explanation. >""" Internally when the when the wrapper determines that a magical transaction is needed it basically executes the following: if isolation_level is not None: .execute('BEGIN %s TRANSACTION;' % (isolation_level,)) if the isolation_level is None then no extra command is issued. if the isolation_level is '' then the command BEGIN TRANSACTION; is issued if the isolation_level is 'DEFERRED' then the command BEGIN DEFERRED TRANSACTION; is issued if the isolation_level is 'IMMEDIATE' then the command BEGIN IMMEDIATE TRANSACTION; is issued if the isolation_level is 'EXCLUSIVE' then the command BEGIN EXCLUSIVE TRANSACTION; is issued The setter for the isolation_level property of the connection ensures that a valid value for isolation_level is being set: if not (not isolation_level or isolation_level.lower() in ('deferred', 'immediate', 'exclusive')): raise ValueError('invalid value for isolation_level') -- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] What is the default value of isolation_level?
So basically an empty string in isolation_level is the same as "DEFERRED"? This is confusing. I think it should have been implemented so that the value of the isolation_level attribute is DEFERRED when it is not specified in .connect(). On 10/25/19, David Raymond wrote: > https://docs.python.org/3.7/library/sqlite3.html#controlling-transactions > > "If you specify no isolation_level, a plain BEGIN is used, which is > equivalent to specifying DEFERRED." > > I believe the empty string qualifies as "no isolation_level" for this. > > > > -Original Message- > From: sqlite-users On Behalf > Of Peng Yu > Sent: Friday, October 25, 2019 3:49 PM > To: SQLite mailing list > Subject: [sqlite] What is the default value of isolation_level? > > Hi, > > isolation_level is an empty string by default as shown below. But the > python manual does not say that it can take an empty string. What does > an empty string mean? Is it equivalent to None? Thanks. > > https://docs.python.org/3/library/sqlite3.html#connection-objects > > """ > isolation_level > > Get or set the current default isolation level. None for > autocommit mode or one of “DEFERRED”, “IMMEDIATE” or “EXCLUSIVE”. See > section Controlling Transactions for a more detailed explanation. > """ > > $ cat main.py > #!/usr/bin/env python2 > import sqlite3 > import sys > conn=sqlite3.connect(sys.argv[1]) > print(repr(conn.isolation_level)) > > $ cat main.sh > #!/usr/bin/env bash > dbfile=$(mktemp -u) > ./main.py "$dbfile" > > $ ./main.sh > '' > > -- > Regards, > Peng > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- Regards, Peng ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] What is the default value of isolation_level?
https://docs.python.org/3.7/library/sqlite3.html#controlling-transactions "If you specify no isolation_level, a plain BEGIN is used, which is equivalent to specifying DEFERRED." I believe the empty string qualifies as "no isolation_level" for this. -Original Message- From: sqlite-users On Behalf Of Peng Yu Sent: Friday, October 25, 2019 3:49 PM To: SQLite mailing list Subject: [sqlite] What is the default value of isolation_level? Hi, isolation_level is an empty string by default as shown below. But the python manual does not say that it can take an empty string. What does an empty string mean? Is it equivalent to None? Thanks. https://docs.python.org/3/library/sqlite3.html#connection-objects """ isolation_level Get or set the current default isolation level. None for autocommit mode or one of “DEFERRED”, “IMMEDIATE” or “EXCLUSIVE”. See section Controlling Transactions for a more detailed explanation. """ $ cat main.py #!/usr/bin/env python2 import sqlite3 import sys conn=sqlite3.connect(sys.argv[1]) print(repr(conn.isolation_level)) $ cat main.sh #!/usr/bin/env bash dbfile=$(mktemp -u) ./main.py "$dbfile" $ ./main.sh '' -- Regards, Peng ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] What is the default value of isolation_level?
On Friday, 25 October, 2019 14:02, Peng Yu wrote: >So basically an empty string in isolation_level is the same as >"DEFERRED"? This is confusing. I think it should have been implemented >so that the value of the isolation_level attribute is DEFERRED when it >is not specified in .connect(). But that would not be dbapi compliant, and the whole point of the pysqlite2 (sqlite3) wrapper is that it is dbapi compliant. This means that the "interface" is the same for a whole raft of things that are all different and attempts to make them all work equally poorly. The 'default' is an empty string ('') simply because that means "do the default thing that the underlying implementation does, and we have absolutely no clue nor do we care what that default is". In the PARTICULAR case of SQLite3 the default is that "BEGIN TRANSACTION;" is the same as "BEGIN DEFERRED TRANSACTION;". However, for HobblinGobblin7 the "BEGIN TRANSACTION;" is the same as "BEGIN OBFUSCATED TRANSACTION;". -- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] What is the default value of isolation_level?
> if the isolation_level is None then no extra command is issued. > if the isolation_level is '' then the command BEGIN TRANSACTION; is issued > if the isolation_level is 'DEFERRED' then the command BEGIN DEFERRED > TRANSACTION; is issued > if the isolation_level is 'IMMEDIATE' then the command BEGIN IMMEDIATE > TRANSACTION; is issued > if the isolation_level is 'EXCLUSIVE' then the command BEGIN EXCLUSIVE > TRANSACTION; is issued I got it. So it is basically from here https://www.sqlite.org/lang_transaction.html "Transactions can be DEFERRED, IMMEDIATE, or EXCLUSIVE. The default transaction behavior is DEFERRED." I still think that python sqlite3 module is better to be implemented to hide this level of detail. Otherwise, users in python will need to know "" is the same as DEFERRED at the raw SQLITE3 level. This information is totally unnecessary burden to a python user. -- Regards, Peng ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] What is the default value of isolation_level?
https://www.sqlite.org/lang_transaction.html Depending on how they're implementing it, one could argue that they're just copying the specs for SQLite and saying "if you're not gonna specify it, then we're not gonna specify it, and we're just gonna let the SQLite library do with it as it pleases without that keyword" -Original Message- From: sqlite-users On Behalf Of Peng Yu Sent: Friday, October 25, 2019 4:02 PM To: SQLite mailing list Subject: Re: [sqlite] What is the default value of isolation_level? So basically an empty string in isolation_level is the same as "DEFERRED"? This is confusing. I think it should have been implemented so that the value of the isolation_level attribute is DEFERRED when it is not specified in .connect(). ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users