1import sqlite3
2conn = sqlite3.connect('example.db')
3c = conn.cursor()
4
5# Create table
6c.execute('''CREATE TABLE stocks
7 (date text, trans text, symbol text, qty real, price real)''')
8
9# Insert a row of data
10c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
11
12# Save (commit) the changes
13conn.commit()
14
15# We can also close the connection if we are done with it.
16# Just be sure any changes have been committed or they will be lost.
17conn.close()