Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sqlite3
  4.  
  5. def main():
  6. conn = sqlite3.connect('example.db')
  7. c = conn.cursor()
  8.  
  9. # Create table
  10. c.execute('''CREATE TABLE example
  11. (key text)''')
  12.  
  13. # Larger example that inserts many records at a time
  14. data = ['first','then','finally']
  15. c.executemany('INSERT INTO example(key) VALUES (?)', zip(data))
  16.  
  17. for row in c.execute('SELECT * FROM example ORDER BY key'):
  18. print(row)
  19.  
  20. if __name__ == '__main__':
  21. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement