Re: [Tutor] sqlite3 COMMIT directive

2013-10-02 Thread Mark Lawrence
On 01/10/2013 12:05, Alan Gauld wrote: On 01/10/13 11:41, Tim Golden wrote: Python, the database starts and ends transactions automatically from within the execute() function. Not so, I'm afraid. If you want autocommit, you need to send an isolation_level of None to the .connect function.

Re: [Tutor] sqlite3 COMMIT directive

2013-10-02 Thread Oscar Benjamin
On 1 October 2013 12:05, Alan Gauld wrote: > > OK, That makes sense it's a bit like the file close at the end of a with > block. So the docs statement that it automatically commits *transactions* is > slightly misleading as it only commits the full content of the block which > could hold multiple

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Tim Golden
On 01/10/2013 11:41, Tim Golden wrote: > You're sort-of correct. What happens is that the database doesn't enter > autocommit mode (you'll still need to specify the right isolation level > on the .connect for that). Rather, the __exit__ method of the > connection-as-context-manager issues the db.co

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Alan Gauld
On 01/10/13 11:41, Tim Golden wrote: Python, the database starts and ends transactions automatically from within the execute() function. Not so, I'm afraid. If you want autocommit, you need to send an isolation_level of None to the .connect function. """ Connection objects can be used as co

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Tim Golden
On 01/10/2013 11:28, Alan Gauld wrote: > On 01/10/13 09:25, Tim Golden wrote: >> On 01/10/2013 09:03, Alan Gauld wrote: >>> You don't normally need to use COMMIT when programming SQLite from >>> Python, the database starts and ends transactions automatically from >>> within the execute() function.

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Alan Gauld
On 01/10/13 09:25, Tim Golden wrote: On 01/10/2013 09:03, Alan Gauld wrote: You don't normally need to use COMMIT when programming SQLite from Python, the database starts and ends transactions automatically from within the execute() function. Not so, I'm afraid. If you want autocommit, you nee

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Alex Kleider
Thank you to respondents. That the code worked at all is something I don't understand. As Alan G pointed out, I had forgotten to include the "cur = con.cursor()" line. After this was corrected and the try/except statement deleted, it worked as I expected. Thanks to "-nick" for pointing me to

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Mark Lawrence
On 01/10/2013 04:16, Alex Kleider wrote: try: cur.execute("COMMIT;") except: pass And the problem = \ """ If the 'cur.execute("COMMIT;")' statement is left by itself, outside of a "try/except" clause, I get an error with the following t

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Tim Golden
On 01/10/2013 09:03, Alan Gauld wrote: > You don't normally need to use COMMIT when programming SQLite from > Python, the database starts and ends transactions automatically from > within the execute() function. You only need to manually commit if you > manually create the transaction using BEGIN..

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Alan Gauld
On 01/10/13 09:03, Alan Gauld wrote: BTW. I notice you are using an implicit cursor within the with block. Now while that may work, my personal preference is for explicit variables, ... Actually I'm not sure how it is working. I've just read the docs again and it seems to me that your code sh

Re: [Tutor] sqlite3 COMMIT directive

2013-10-01 Thread Alan Gauld
On 01/10/13 04:16, Alex Kleider wrote: And the problem = \ """ If the 'cur.execute("COMMIT;")' statement is left by itself, outside of a "try/except" clause, I get an error with the following trace back: " Traceback (most recent call last): File "./uwomeds68.py", line 119, in go_on.inse

Re: [Tutor] sqlite3 COMMIT directive

2013-09-30 Thread Dominik George
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi, >sqlite3.OperationalError: cannot commit - no transaction is active That means that you have to execute "BEGIN TRANSACTION" before using atomic commits. http://www.sqlite.org/lang_transaction.html http://sqlite.org/transactional.html >I've b

[Tutor] sqlite3 COMMIT directive

2013-09-30 Thread Alex Kleider
I'm just beginning to enter into the field of database and SQLite in particular. Python 2.7 on Ubuntu The problem code is a class method defined as follows: def insert(self, DataBase=DataBase, Table=Table): """ Insert instance of ClassMate into . """ con =