Skip to content

Instantly share code, notes, and snippets.

/sqlite.py Secret

Created June 16, 2015 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/cf30c11fec8cb082deaa to your computer and use it in GitHub Desktop.
Save anonymous/cf30c11fec8cb082deaa to your computer and use it in GitHub Desktop.
import sqlite3
conn = sqlite3.connect('example.db')
conn.execute("CREATE TABLE tbl (id INTEGER PRIMARY KEY, someint INTEGER)");
conn.execute("INSERT INTO tbl (id, someint) VALUES (1, 3)");
conn.execute("INSERT INTO tbl (id, someint) VALUES (2, 4)");
result = conn.execute('SELECT * FROM tbl');
conn.execute('UPDATE tbl SET someint = 5 WHERE id = 1');
conn.execute('UPDATE tbl SET someint = 6 WHERE id = 2');
for item in result:
print item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment