fork download
  1. import sqlite3
  2. conn = sqlite3.connect('example.db')
  3. c = conn.cursor()
  4.  
  5. # Create table
  6. c.execute('''CREATE TABLE stocks
  7. (date text, trans text, symbol text, qty real, price real)''')
  8.  
  9. # Insert a row of data
  10. c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)")
  11.  
  12. # Save (commit) the changes
  13. conn.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.
  17. conn.close()
Runtime error #stdin #stdout #stderr 0s 11264KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 2, in <module>
sqlite3.OperationalError: unable to open database file