Posted By

manatlan on 09/09/09


Tagged

python SQLite


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

gartenstuhl


sqlite use cases


 / Published in: Python
 

  1. import sqlite3
  2.  
  3. c = sqlite3.connect('medialib.db')
  4. sql="SELECT name FROM sqlite_master WHERE type='table';"
  5. r=c.execute(sql)
  6. for row in r.fetchall():
  7. print row
  8.  
  9. cur = c.cursor()
  10. cur.execute('CREATE TABLE foo (o_id INTEGER PRIMARY KEY, fruit VARCHAR(20), veges VARCHAR(30))')
  11. con.commit()
  12. cur.execute('INSERT INTO foo (o_id, fruit, veges) VALUES(NULL, "apple", "broccoli")')
  13. con.commit()
  14. print cur.lastrowid

Report this snippet  

You need to login to post a comment.