sqlite3 bug??

Carsten Haese carsten at uniqsys.com
Sun Jun 17 14:12:04 CEST 2007


On Sun, 2007-06-17 at 12:59 +0100, mark carter wrote:
> I hesitate to ask, but ...
> 
> I'm using Ubuntu Feisty:
> * Python 2.5.1 (r251:54863, May  2 2007, 16:56:35)
> 	[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
> * SQLite version 3.3.13
> 
> Suppose I run the following program:
> import sqlite3
> 
> conn = sqlite3.connect('example')
> 
> 
> c = conn.cursor()
> 
> # Create table
> c.execute('''create table stocks
> (date text, trans text, symbol text,
>   qty real, price real)''')
> 
> # Insert a row of data
> c.execute("""insert into stocks
>            values ('2006-01-05','BUY','RHAT',100,35.14)""")
> 
> and then I go into sqlite:
> % sqlite3 example
> sqlite3> select * from stocks ;
> 
> It returns 0 rows. 

Your program doesn't call conn.commit(). Python's DB-API specifies that
a connection operate in a transaction by default. The transaction is
rolled back at the end of the program if it's not committed.

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list