Guide
This guide walks through sqlc-gen-better-python one feature at a time. Each
page states what a feature does, the configuration it needs, and shows real
schema, queries, and the exact Python the plugin generates for them.
How the pieces fit
You never call this plugin directly. You write a SQL schema and queries, and
sqlc runs the plugin for you:
- You write schema (
CREATE TABLE,CREATE TYPE) and queries (annotatedSELECT/INSERT/…). sqlcparses them into a typed catalog and hands it to the plugin.- The plugin walks the catalog and emits Python: a
models.py(one class per table), one query module per query.sqlfile (typed functions), and anenums.pywhen your schema has enums.
So everything in this guide is driven by two inputs - your SQL and your
sqlc.yaml options - and observed through one output: the generated Python.
sqlc generate, then come back to this guide.How to read this guide
Start with the essentials, then dip into feature pages as you need them:
The remaining pages - enums, type overrides, converters, working with JSON, docstrings, SQLite type conversion, and naming - cover specific features and can be read in any order. The Reference section holds the canonical option, type-mapping, and driver-support tables.