On Friday, 25 October, 2019 13:49, Peng Yu <pengyu...@gmail.com> 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