Skip to content

Instantly share code, notes, and snippets.

@tamsanh
Created July 5, 2023 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamsanh/7588f06b22df2c777b48d87ddaa1385d to your computer and use it in GitHub Desktop.
Save tamsanh/7588f06b22df2c777b48d87ddaa1385d to your computer and use it in GitHub Desktop.
Generate python sql functions with sqlc
---
version: "2"
plugins:
- name: py
wasm:
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.0.0.wasm
sha256: aca83e1f59f8ffdc604774c2f6f9eb321a2b23e07dc83fc12289d25305fa065b
sql:
- schema: schema.sql # This is the basis for all generated queries
queries: ../queries.sql # Queries to generate
engine: postgresql # The engine to use
codegen:
- out: ../sqlc/generated # Output directory
plugin: py
options:
package: generated # Python package name
emit_sync_querier: true
emit_async_querier: true
# Requires sqlc to be installed via brew
# With the config.sqlc.yaml, we leverage the python plugin to create a python version of
# our queries.
sqlc generate -f config.sqlc.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment