Sto iniziando a scrivere il mio primo codice python Ecco: ################ import sqlite3 conn = sqlite3.connect('esempio-stocks.sqlite') c = conn.cursor()
try: c.execute('DROP TABLE stocks') except: pass # Create table c.execute('''create table stocks (date text, trans text, symbol text, qty real, price real)''') ### questo funzione # Insert a row of data c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""") #######questo funziona # Larger example for t in [('2006-03-28', 'BUY','u', 1000, 45.00), ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00), ('2006-04-06', 'SELL', 'IBM', 500, 53.00), ]: c.execute('insert into stocks values (?,?,?,?,?)', t) ###########questo funziona c.execute('select * from stocks order by price') for row in c: print row ####### questo ( è copiato da Active Python 2.6 documentation...)mi da ########## Traceback (most recent call last): ########## File "<string>", line 38, in <fragment> ##########sqlite3.OperationalError: cannot commit transaction - SQL statements in ###########progress # Do this instead symbol= 'IBM' t = (symbol,) c.execute('select * from stocks where symbol=?', t) # Save (commit) the changes conn.commit() # We can also close the cursor if we are done with it c.close() ---------------------------------------- domanda: perché? Domanda: esite una documentazione CON ESEMPI di Sqlite e Python? O almeno una documentazione del solo Sqlite CON ESEMPI ? Mi interessa perché python mi servirà più che altro per gestione databases locali. La somma di python e sqlite mi ricorda il vecchissimmo dBase e Clipper. Grazie Filippo _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python