Re: Transaction isolation
Pawel Lewicki <lewicki-0xdmosgkavurDJvtcaxF/[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Gerhard Häring pisze: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Pawel Lewicki wrote: >> Hi, >> I tried to find information about my problem but no clear solution so far. >> What should I do to keep transactions isolated? > > That's easy. Use pysqlite2 the standard way and don't try to issue BEGIN, > COMMIT or ROLLBACK statements via execute calls. > > Connections are started implicitly once you execute() a DML (data > modification language) command like DELETE, INSERT, UPDATE, REPLACE. > > To make your data modifications permament, use the .commit() method of the > connection object. > > To throw away the changes of the current transation, use the .rollback() > method of the connection object. > > There are quite a few problems in the following code of yours ... Thanks a lot for your comments. I'll try tomorrow updated code. I'm really sorry for stupid mistake. I used a snippet from this list as a reference and unintentionally copied its mistakes and added my own. I wanted to show a simple piece of the code to discuss transaction issue, nothing more. Code itself is fine, I just wanted to ask how make sure that the second connection will always query for consistent data (only first connection is modifying anything). Pawel Lewicki