Already installed, already useful
Python ships sqlite3 in the standard library. No pip install, no extra dependency. The module wraps the C SQLite library that comes bundled with CPython.
The minimum-viable usage:
import sqlite3
conn = sqlite3.connect('myapp.db')
conn.execute('CREATE TABLE IF NOT EXISTS notes(id INTEGER PRIMARY KEY, body TEXT)')
conn.execute('INSERT INTO notes(body) VALUES (?)', ('hello',))
conn.commit()
for row in conn.execute('SELECT * FROM notes'):
print(row)
conn.close()That works, but it skips most of what you should know. The next nine lessons fill that in. The key first checks:
sqlite3.sqlite_version— the bundled libsqlite version (often older than the system CLI).sqlite3.version— the Python module version (less interesting).- Use
conn.row_factory = sqlite3.Rowto get dict-like access — covered in lesson py05.
Tip: If your CLI sqlite3 is much newer than Python's bundled libsqlite, install
pysqlite3-binary and import that instead — same API, newer engine, supports STRICT/JSONB/etc.