|
38 | 38 | More options at the [`sqlc` config reference](https://docs.sqlc.dev/en/stable/reference/config.html) |
39 | 39 |
|
40 | 40 | ## Configuration Options |
41 | | -| Name | Type | Required | Description | |
42 | | -|----------------------------------|--------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
43 | | -| `package` | string | yes | The name of the package where the generated files will be located | |
44 | | -| `emit_init_file` | bool | yes | If set to to `false` there will be no `__init__.py` file created in the package that you specified. Only set this to false if you know that you already have a `__init__.py` file otherwise the generated code wont work. | |
45 | | -| `sql_driver` | string | no | The name of the sql driver you want to use. Defaults to `aiosqlite`. Valid options are listed [here](#feature-support) | |
46 | | -| `model_type` | string | no | The model type you want to use. This can be one of `dataclass`, `msgspec` or `attrs`. Defaults to `dataclass` | |
47 | | -| `initialisms` | list[string] | no | An array of [initialisms](https://google.github.io/styleguide/go/decisions.html#initialisms) to upper-case. For example, `app_id` becomes `AppID`. Defaults to `["id"]`. | |
48 | | -| `emit_exact_table_names` | bool | no | If `true`, model names will mirror table names. Otherwise sqlc attempts to singularize plural table names. | |
49 | | -| `emit_classes` | bool | no | If `true`, every query function will be put into a class called `Querier`. Otherwise every function will be a standalone function. | |
50 | | -| `inflection_exclude_table_names` | list[string] | no | An array of table names that should not be turned singular. Only applies if `emit_exact_table_names` is `false`. | |
51 | | -| `omit_unused_models` | bool | no | If set to `true` and there are models/tables that are not used in any query, they wont be turned into models. | |
52 | | -| `docstrings` | string | no | If set, there will be docstrings generated in the selected format. This can be one of `google`, `numpy`, `pep257` and `none`. `none` will not generate any docstrings. | |
53 | | -| `docstrings_emit_sql` | bool | no | If set to `false` the SQL code for each query wont be included in the docstrings. This defaults to `true` but is not used when `docstrings` is not set or set to `none` | |
54 | | -| `query_parameter_limit` | integer | no | Not yet implemented. | |
55 | | -| `speedups` | bool | no | If set to `true` the plugin will use other librarys for type conversion. Needs extra dependecys to be installed. This option currently only affects `sqlite3` & `aiosqlite` and uses the library `ciso8601` | |
56 | | -| `debug` | bool | no | If set to `true`, there will be debug logs generated into a `log.txt` file when executing `sqlc generate`. Defaults to `false` | |
| 41 | +| Name | Type | Required | Description | |
| 42 | +|----------------------------------|----------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 43 | +| `package` | string | yes | The name of the package where the generated files will be located | |
| 44 | +| `emit_init_file` | bool | yes | If set to to `false` there will be no `__init__.py` file created in the package that you specified. Only set this to false if you know that you already have a `__init__.py` file otherwise the generated code wont work. | |
| 45 | +| `sql_driver` | string | no | The name of the sql driver you want to use. Defaults to `aiosqlite`. Valid options are listed [here](#feature-support) | |
| 46 | +| `model_type` | string | no | The model type you want to use. This can be one of `dataclass`, `msgspec` or `attrs`. Defaults to `dataclass` | |
| 47 | +| `initialisms` | list[string] | no | An array of [initialisms](https://google.github.io/styleguide/go/decisions.html#initialisms) to upper-case. For example, `app_id` becomes `AppID`. Defaults to `["id"]`. | |
| 48 | +| `emit_exact_table_names` | bool | no | If `true`, model names will mirror table names. Otherwise sqlc attempts to singularize plural table names. | |
| 49 | +| `emit_classes` | bool | no | If `true`, every query function will be put into a class called `Querier`. Otherwise every function will be a standalone function. | |
| 50 | +| `inflection_exclude_table_names` | list[string] | no | An array of table names that should not be turned singular. Only applies if `emit_exact_table_names` is `false`. | |
| 51 | +| `omit_unused_models` | bool | no | If set to `true` and there are models/tables that are not used in any query, they wont be turned into models. | |
| 52 | +| `docstrings` | string | no | If set, there will be docstrings generated in the selected format. This can be one of `google`, `numpy`, `pep257` and `none`. `none` will not generate any docstrings. | |
| 53 | +| `docstrings_emit_sql` | bool | no | If set to `false` the SQL code for each query wont be included in the docstrings. This defaults to `true` but is not used when `docstrings` is not set or set to `none` | |
| 54 | +| `query_parameter_limit` | integer | no | Not yet implemented. | |
| 55 | +| `speedups` | bool | no | If set to `true` the plugin will use other librarys for type conversion. Needs extra dependecys to be installed. This option currently only affects `sqlite3` & `aiosqlite` and uses the library `ciso8601` | |
| 56 | +| `overrides` | list[Override] | no | A list of [type overrides](#type-overrides). | |
| 57 | +| `debug` | bool | no | If set to `true`, there will be debug logs generated into a `log.txt` file when executing `sqlc generate`. Defaults to `false` | |
| 58 | + |
| 59 | +### Type Overrides |
| 60 | +Similar to `sqlc-gen-go` this plugin supports overriding types with your own. You can either override the type of every column that has a specific sql type, or you can overwrite the type of specific columns. |
| 61 | + |
| 62 | +```yaml |
| 63 | +# filename: sqlc.yaml |
| 64 | +# ... |
| 65 | + options: |
| 66 | + # ... |
| 67 | + overrides: |
| 68 | + - db_type: text |
| 69 | + py_type: |
| 70 | + import: collections |
| 71 | + package: UserString |
| 72 | + type: UserString |
| 73 | + - column: table_name.text_column |
| 74 | + py_type: |
| 75 | + import: collections |
| 76 | + type: collections.UserString |
| 77 | + |
| 78 | +``` |
57 | 79 |
|
58 | 80 | ## Feature Support |
59 | 81 | Every [sqlc macro](https://docs.sqlc.dev/en/latest/reference/macros.html) is supported. |
|
0 commit comments