SQLite with the sqlite3 Stdlib
Create a table, insert rows, and query with parameterized SQL.
Author:
chris
// Language: Python
import sqlite3
with sqlite3.connect('app.db') as conn:
cur = conn.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)')
cur.executemany('INSERT INTO users (name) VALUES (?)',
[('Alice',), ('Bob',), ('Eve',)])
conn.commit()
for row in cur.execute('SELECT id, name FROM users ORDER BY name'):
print(row)