{"id":37107168,"url":"https://github.com/rayakame/sqlc-gen-better-python","last_synced_at":"2026-01-14T12:53:17.778Z","repository":{"id":284453192,"uuid":"954937130","full_name":"rayakame/sqlc-gen-better-python","owner":"rayakame","description":"SQLC plugin adding support for Python code generation","archived":false,"fork":false,"pushed_at":"2025-12-10T09:41:44.000Z","size":13558,"stargazers_count":15,"open_issues_count":7,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-10T12:20:58.272Z","etag":null,"topics":["mysql","postgresql","python","python3","sql","sqlc","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rayakame.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-25T21:08:11.000Z","updated_at":"2025-12-10T09:41:47.000Z","dependencies_parsed_at":"2025-03-26T01:25:29.264Z","dependency_job_id":"376cfebe-f489-48ea-9848-86b0308094b8","html_url":"https://github.com/rayakame/sqlc-gen-better-python","commit_stats":null,"previous_names":["rayakame/sqlc-gen-better-python"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/rayakame/sqlc-gen-better-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayakame%2Fsqlc-gen-better-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayakame%2Fsqlc-gen-better-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayakame%2Fsqlc-gen-better-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayakame%2Fsqlc-gen-better-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rayakame","download_url":"https://codeload.github.com/rayakame/sqlc-gen-better-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rayakame%2Fsqlc-gen-better-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql","postgresql","python","python3","sql","sqlc","sqlite3"],"created_at":"2026-01-14T12:53:17.291Z","updated_at":"2026-01-14T12:53:17.768Z","avatar_url":"https://github.com/rayakame.png","language":"Python","readme":"# sqlc-gen-better-python\n\n[![Codecov](https://codecov.io/gh/rayakame/sqlc-gen-better-python/graph/badge.svg?token=LROCMXW6MC)](https://codecov.io/gh/rayakame/sqlc-gen-better-python)\n![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Frayakame%2Fsqlc-gen-better-python%2Fmain%2Fpyproject.toml)\n![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)\n[![CI](https://github.com/rayakame/sqlc-gen-better-python/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/rayakame/sqlc-gen-better-python/actions/workflows/ci.yml)\n\nA WASM plugin for SQLC allowing the generation of Python code.\n\n\n\u003e [!NOTE]  \n\u003e Every Release before `v1.0.0`, including this one is an beta release. \n\u003e These versions are primarly released for interested people who want to test this plugin and help make it better.\n\u003e\n\u003e I want to be very open about the current state of the project. Everything that is implemented works, and is beeing used\n\u003e in production envirouments already. But there are some drivers and features that are sadly not implemented yet, biggest one\n\u003e beeing that enums don't have support yet. I am working on that but I have a lot of stuff todo at the moment so I can't give a clear\n\u003e estimate on how long this is going to take. Feel free to lmk any wanted features and I'm going to do my best on implementing them with\n\u003e the time I have rn.\n\n\n## Example Config\n\n```yaml\n# filename: sqlc.yaml\nversion: \"2\"\nplugins:\n  - name: python\n    wasm:\n      url: https://github.com/rayakame/sqlc-gen-better-python/releases/download/v0.4.5/sqlc-gen-better-python.wasm\n      sha256: 9b42f7cffda942388470e777af957ec8ab03cbea9124ff8c49bef05f9d00cb66\nsql:\n  - engine: \"postgresql\"\n    queries: \"query.sql\"\n    schema: \"schema.sql\"\n    codegen:\n      - out: \"app/db\"\n        plugin: python\n        options:\n          package: \"db\"\n          emit_init_file: true\n          sql_driver: \"asyncpg\"\n          model_type: \"msgspec\"\n\n```\n\nMore options at the [`sqlc` config reference](https://docs.sqlc.dev/en/stable/reference/config.html)\n\n## Configuration Options\n\n| Name                             | Type           | Required | Description                                                                                                                                                                                                               |\n|----------------------------------|----------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `package`                        | string         | yes      | The name of the package where the generated files will be located                                                                                                                                                         |\n| `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. |\n| `sql_driver`                     | string         | no       | The name of the sql driver you want to use. Defaults to `aiosqlite`. Valid options are listed [here](#feature-support)                                                                                                    |\n| `model_type`                     | string         | no       | The model type you want to use. This can be one of `dataclass`, `msgspec` or `attrs`. Defaults to `dataclass`                                                                                                             |\n| `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\"]`.                                                  |\n| `emit_exact_table_names`         | bool           | no       | If `true`, model names will mirror table names. Otherwise sqlc attempts to singularize plural table names.                                                                                                                |\n| `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.                                                                                        |\n| `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`.                                                                                                          |\n| `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.                                                                                                             |\n| `omit_typechecking_block`        | bool           | no       | If set to `true`, will not wrap all non-builtin types behind a `typing.TYPE_CHECKING` block. Defaults to `false`                                                                                                          |\n| `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.                                                    |\n| `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`                                                   |\n| `query_parameter_limit`          | integer        | no       | Not yet implemented.                                                                                                                                                                                                      |\n| `omit_kwargs_limit`              | integer        | no       | This can be used to set a limit where any query with less or equal amounts of parameters will not require kwargs for the parameters. This defaults to `0` which makes every query require kwargs for their parameters.    |\n| `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` \u0026 `aiosqlite` and uses the library `ciso8601`               |\n| `overrides`                      | list[Override] | no       | A list of [type overrides](#type-overrides).                                                                                                                                                                              |\n| `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`                                                                                            |\n\n### Type Overrides\n\nSimilar to `sqlc-gen-go` this plugin supports overriding types with your own. You can either override the type of every\ncolumn that has a specific sql type, or you can overwrite the type of specific columns.\n\n```yaml\n# filename: sqlc.yaml\n# ...\noptions:\n  # ...\n  overrides:\n    - db_type: text\n      py_type:\n        import: collections\n        package: UserString\n        type: UserString\n    - column: table_name.text_column\n      py_type:\n        import: collections\n        type: collections.UserString\n\n```\n\n## Feature Support\n\nEvery [sqlc macro](https://docs.sqlc.dev/en/latest/reference/macros.html) is supported.\nThe supported [query commands](https://docs.sqlc.dev/en/latest/reference/query-annotations.html) depend on the SQL\ndriver you are using, supported commands are listed below.\n\u003e Every `:batch*` command is not supported by this plugin and probably will never be.\n\n\u003e Prepared Queries are not planned for the near future, but will be implemented sooner or later\n\n|           | `:exec` | `:execresult` | `:execrows` | `:execlastid` | `:many` | `:one` | `:copyfrom` |\n|-----------|---------|---------------|-------------|---------------|---------|--------|-------------|\n| aiosqlite | yes     | yes           | yes         | yes           | yes     | yes    | no          |\n| sqlite3   | yes     | yes           | yes         | yes           | yes     | yes    | no          |\n| asyncpg   | yes     | yes           | yes         | no            | yes     | yes    | yes         |\n| psycopg2  | no      | no            | no          | no            | no      | no     | no          |\n| mysql     | no      | no            | no          | no            | no      | no     | no          |\n\n## Development\n\nA roadmap of what is planned \u0026 worked on can be found [here](https://github.com/users/rayakame/projects/1/).\n\nContributions are very welcome, for more information and help please read\nthe [contribution guidelines](https://github.com/rayakame/sqlc-gen-better-python/blob/main/CONTRIBUTING.md).\n\n### Changelog\n\nCan be found [here](https://github.com/rayakame/sqlc-gen-better-python/blob/main/CHANGELOG.md)\n\n## Credits\n\nBecause of missing documentation about creating these plugins, this work is heavily\ninspired by:\n\n- [sqlc-gen-go](https://github.com/sqlc-dev/sqlc-gen-go)\n- [sqlc-gen-java](https://github.com/tandemdude/sqlc-gen-java)\n\nSpecial thanks to [tandemdude](https://github.com/tandemdude) for answering my questions on discord.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frayakame%2Fsqlc-gen-better-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frayakame%2Fsqlc-gen-better-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frayakame%2Fsqlc-gen-better-python/lists"}