I am completely new to the sqlite3 Python module (and generally SQL in this case), and it's just a complete stump. The abundant lack of descriptions of cursor objects (rather, their necessity) also seems strange.
This piece of code is the preferred way:
import sqlite3 conn = sqlite3.connect("db.sqlite") c = conn.cursor() c.execute('''insert into table "users" values ("Jack Bauer", "555-555-5555")''') conn.commit() c.close()
This is not, although it works just as well without the (seemingly meaningless) cursor :
import sqlite3 conn = sqlite3.connect("db.sqlite") conn.execute('''insert into table "users" values ("Jack Bauer", "555-555-5555")''') conn.commit()
Can someone tell me why i cursor ?
It just seems pointless overhead. For each method in my script that accesses the database, do I have to create and destroy the cursor ?
Why not just use the connection object?
python sqlite sqlite3 cursor
Jack Bauer Jun 11 '11 at 19:41 2011-06-11 19:41
source share