sqlite use cases


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.