Advertisement
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(row)
- print("Results from a LIKE query:")
- sql = "SELECT * FROM albums WHERE title LIKE 'The%'"
- cursor.execute(sql)
- print(cursor.fetchall())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement