Yes.  pysqlite/sqlite3 in python tries to manage transactions for you by 
automatically starting them, and you need to commit them yourself.  This is 
controlled by the isolation_level attribute set on the connection (can also be 
set as a parameter when you open the connection).

The default value is '' (an empty string).  Other valid values are 'IMMEDIATE', 
'EXCLUSIVE' and None.  Basically, pysqlite tries to detect the type of 
statement you are running and if it is a DML statement (select, insert, update, 
delete) it automatically begins a transaction for you if one is not in progress 
by first doing a 'BEGIN '+isolation_level.  If the statement is something other 
than DML, then it will 'COMMIT' before executing the DDL (CREATE/DROP) then it 
will 'COMMIT' after executing it.  It does not know about the "WITH" statement, 
so treats those as DDL rather than DML.

Setting isolation_level to None tells pysqlite/sqlite3 to not manage 
transactions and let the SQLite3 engine do it as it would from the C interface 
or the sqlite3.exe command line tool (what the dbapi calls autocommit mode), so 
you have to issue your own BEGIN and COMMIT/ROLLBACK commands where you want 
them and the pysqlite/sqlite3 interface modules will not attempt to begin or 
commit transactions for you.

On Friday, 3 October, 2014 21:48, you wrote:

>Ah, ok.  after doing a database commit I get the error going to stderr.
>Now it's just a matter
>of capturing/redirecting the stderr output and using an except there.


>On Friday, October 03, 2014 11:35:08 PM you wrote:
>> the sqlite3 command line doesn't require a commit, it gave an error
>> after the attempted insert command.
>>
>> pysqlite requires one?
>>
>> Mark
>>
>> On Friday, October 03, 2014 09:06:56 PM Keith Medcalf wrote:
>> > Are you committing the change?
>> >
>> > >-----Original Message-----
>> > >From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
>> > >boun...@sqlite.org] On Behalf Of Mark Halegua
>> > >Sent: Friday, 3 October, 2014 20:58
>> > >To: sqlite-users@sqlite.org
>> > >Subject: [sqlite] passing error messages to pysqlite
>> > >
>> > >I have a sqlite3 database.  In the networkied are I have the db is
>locked
>> > >(wee've
>> > >discussed this before, and I'm using it mostly on a local machine,
>but I
>> > >need to
>> > >test certain conditions, networking being one).
>> > >
>> > >In the sqlite3 command line, when I try to insert new info I get a
>dabase
>> > >locked
>> > >message.
>> > >
>> > >Hosever, when I do the same in python with pysqlite, it doesn't
>return
>> > >anything
>> > >and the code proceeds as if nothing happened, and the program just
>goes
>> > >on,
>> > >even though the data wasn't saved/
>> > >
>> > >I'm sure some message is being returned to pysqlite, how do I
>capture it
>> > >to set up
>> > >an error trap/condition?
>> > >
>> > >Thanks
>> > >_______________________________________________
>> > >sqlite-users mailing list
>> > >sqlite-users@sqlite.org
>> > >http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>> >
>> > _______________________________________________
>> > sqlite-users mailing list
>> > sqlite-users@sqlite.org
>> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@sqlite.org
>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to