with one click
turbopg
// Use TurboPG for standalone Postgres queries. Use when writing database code outside of TurboAPI routes, running migrations, seeding data, or building scripts that talk to Postgres.
// Use TurboPG for standalone Postgres queries. Use when writing database code outside of TurboAPI routes, running migrations, seeding data, or building scripts that talk to Postgres.
Run performance benchmarks for TurboAPI. Use when testing performance, checking for regressions, or comparing against FastAPI.
Build the TurboAPI Zig native backend. Use when the turbonet extension needs to be recompiled, after changing Zig source files, or when seeing "Native core not available".
Scaffold Zig-native database routes using pg.zig + TurboPG. Use when adding database-backed CRUD endpoints, custom SQL queries (pgvector, JSONB, full-text search, JOINs, CTEs), or standalone TurboPG usage.
Scaffold a new TurboAPI route with handler, model, and tests. Use when adding a new API endpoint, creating a new route, or scaffolding CRUD for a resource.
Run TurboAPI tests. Use when running tests, checking for regressions, or verifying changes.
| name | turbopg |
| description | Use TurboPG for standalone Postgres queries. Use when writing database code outside of TurboAPI routes, running migrations, seeding data, or building scripts that talk to Postgres. |
TurboPG ships with TurboAPI and works independently for any Python Postgres work.
from turbopg import Database
db = Database("postgres://user:pass@localhost/mydb", pool_size=16)
# Multiple rows
users = db.query("SELECT * FROM users WHERE age > $1 LIMIT $2", [18, 10])
# Single row (or None)
user = db.query_one("SELECT * FROM users WHERE id = $1", [42])
# Execute (INSERT/UPDATE/DELETE) — returns affected row count
db.execute("INSERT INTO users (name, email) VALUES ($1, $2)", ["Alice", "a@b.com"])
affected = db.execute("DELETE FROM users WHERE id = $1", [99])
# Context manager
with Database("postgres://...") as db:
count = db.query_one("SELECT count(*) as n FROM users")
Use $1, $2, ... for parameterized queries (Postgres-native, SQL injection safe):
db.query("SELECT * FROM users WHERE name = $1 AND age > $2", ["Alice", 18])
query() → list[dict] — each row as a dict with column names as keysquery_one() → dict | None — first row or Noneexecute() → int — number of affected rowsfloat, datetimes → ISO string, memoryview → decoded stringpip install psycopg2-binary)db = Database("postgres://user:pass@/var/run/postgresql/mydb")
TurboPG powers TurboAPI's db_get, db_post, db_list, db_delete, and db_query decorators. The Zig-native path runs the entire request cycle without Python.