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