a guest Apr 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import sqlite3
- conn = sqlite3.connect("mydatabase.db")
- #conn.row_factory = sqlite3.Row
- cursor = conn.cursor()
- sql = "SELECT * FROM albums WHERE artist=?"
- cursor.execute(sql, [("Red")])
- print(cursor.fetchall()) # or use fetchone()
- print("Here's a listing of all the records in the table:")
- for row in cursor.execute("SELECT rowid, * FROM albums ORDER BY artist"):
- print("Results from a LIKE query:")
- sql = "SELECT * FROM albums WHERE title LIKE 'The%'"
RAW Paste Data