Re: [pysqlite] transaction and DML statement
Gerhard Häring <[email protected]> Thu, 21 Aug 2008 11:54:44 +0200
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Sylvain Thénault wrote:
> Hi there,
>
> some time ago I posted a ticket [1] in regards to the fact that pysqlite
> was emitting as COMMIT before a DML statement was executed. This ticket
> has been rejected for backward compatibility reason. Fine, but I still
> can't find a way to avoid this, while the documentation states [2]:
>
> "By default, pysqlite opens transactions implicitly before a DML
> statement (INSERT/UPDATE/DELETE/REPLACE), and commits transactions
> implicitly before a non-DML, non-DQL statement (i. e. anything other
> than SELECT/INSERT/UPDATE/DELETE/REPLACE)."
>
> "By default" makes me think that I can do something to avoid this
> behaviour, but I can't find what... The connexion's isolation_level
> attribute mentionned seems to only control the type of BEGIN statement
> emited. Did I miss something ? [...]
isolation_level has a special behaviour for "None": autocommit mode, i.
e. no implicit transaction handling from pysqlite at all.
Which is is probably what you wanted, right?
con = sqlite.connect(..., isolation_level=None)
# or:
con.isolation_level = None
cur = con.cursor()
cur.execute("BEGIN")
cur.execute("CREATE ...")
cur.execute("CREATE ...")
cur.execute("COMMIT")
# switch back isolation level:
con.isolation_level = "" # SQLite default
con.isolation_level = "IMMEDIATE" # etc.
-- Gerhard
_______________________________________________
list-pysqlite mailing list
[email protected]
http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite