Skip to content

Commit 1f7fd85

Browse files
committed
docs: add docs for emit_str_enum
1 parent b3f2471 commit 1f7fd85

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

README.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
## Usage
22

33
```yaml
4-
version: '2'
4+
version: "2"
55
plugins:
6-
- name: py
7-
wasm:
8-
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.2.0.wasm
9-
sha256: a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e
6+
- name: py
7+
wasm:
8+
url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.2.0.wasm
9+
sha256: a6c5d174c407007c3717eea36ff0882744346e6ba991f92f71d6ab2895204c0e
1010
sql:
11-
- schema: "schema.sql"
12-
queries: "query.sql"
13-
engine: postgresql
14-
codegen:
15-
- out: src/authors
16-
plugin: py
17-
options:
18-
package: authors
19-
emit_sync_querier: true
20-
emit_async_querier: true
11+
- schema: "schema.sql"
12+
queries: "query.sql"
13+
engine: postgresql
14+
codegen:
15+
- out: src/authors
16+
plugin: py
17+
options:
18+
package: authors
19+
emit_sync_querier: true
20+
emit_async_querier: true
2121
```
22+
23+
### Emit Pydantic Models instead of `dataclasses`
24+
25+
Option: `emit_pydantic_models`
26+
27+
By default, `sqlc-gen-python` will emit `dataclasses` for the models. If you prefer to use [`pydantic`](https://docs.pydantic.dev/latest/) models, you can enable this option.
28+
29+
### Use `enum.StrEnum` for Enums
30+
31+
Option: `emit_str_enum`
32+
33+
`enum.StrEnum` was introduce in Python 3.11.
34+
35+
`enum.StrEnum` is a subclass of `str` that is also a subclass of `Enum`. This allows for the use of `Enum` values as strings, compared to strings, or compared to other `enum.StrEnum` types.
36+
37+
This is convenient for type checking and validation, as well as for serialization and deserialization.
38+
39+
By default, `sqlc-gen-python` will emit `(str, enum.Enum)` for the enum classes. If you prefer to use `enum.StrEnum`, you can enable this option.

0 commit comments

Comments
 (0)