SHARE
TWEET

Untitled

a guest Apr 18th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sqlite3
  2.  
  3. conn = sqlite3.connect("mydatabase.db")
  4. #conn.row_factory = sqlite3.Row
  5. cursor = conn.cursor()
  6.  
  7. sql = "SELECT * FROM albums WHERE artist=?"
  8. cursor.execute(sql, [("Red")])
  9. print(cursor.fetchall()) # or use fetchone()
  10.  
  11. print("Here's a listing of all the records in the table:")
  12. for row in cursor.execute("SELECT rowid, * FROM albums ORDER BY artist"):
  13.     print(row)
  14.  
  15. print("Results from a LIKE query:")
  16. sql = "SELECT * FROM albums WHERE title LIKE 'The%'"
  17. cursor.execute(sql)
  18.  
  19. print(cursor.fetchall())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top