{"id":13434624,"url":"https://github.com/sqlc-dev/sqlc-gen-python","last_synced_at":"2025-04-04T09:06:12.576Z","repository":{"id":61679427,"uuid":"548530161","full_name":"sqlc-dev/sqlc-gen-python","owner":"sqlc-dev","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-24T04:53:01.000Z","size":126,"stargazers_count":204,"open_issues_count":37,"forks_count":26,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T08:04:39.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/sqlc-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2022-10-09T18:59:50.000Z","updated_at":"2025-03-20T18:52:27.000Z","dependencies_parsed_at":"2023-01-21T17:47:30.233Z","dependency_job_id":"699e7044-be9e-46f5-ad54-e9b2efd839c0","html_url":"https://github.com/sqlc-dev/sqlc-gen-python","commit_stats":null,"previous_names":["sqlc-dev/sqlc-gen-python"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlc-dev%2Fsqlc-gen-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqlc-dev","download_url":"https://codeload.github.com/sqlc-dev/sqlc-gen-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149500,"owners_count":20891954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-31T03:00:19.116Z","updated_at":"2025-04-04T09:06:12.553Z","avatar_url":"https://github.com/sqlc-dev.png","language":"Go","funding_links":[],"categories":["Supported languages","Go"],"sub_categories":[],"readme":"## Usage\n\n```yaml\nversion: \"2\"\nplugins:\n  - name: py\n    wasm:\n      url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.3.0.wasm\n      sha256: fbedae96b5ecae2380a70fb5b925fd4bff58a6cfb1f3140375d098fbab7b3a3c\nsql:\n  - schema: \"schema.sql\"\n    queries: \"query.sql\"\n    engine: postgresql\n    codegen:\n      - out: src/authors\n        plugin: py\n        options:\n          package: authors\n          emit_sync_querier: true\n          emit_async_querier: true\n```\n\n### Emit Pydantic Models instead of `dataclasses`\n\nOption: `emit_pydantic_models`\n\nBy 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.\n\nwith `emit_pydantic_models`\n\n```py\nfrom pydantic import BaseModel\n\nclass Author(pydantic.BaseModel):\n    id: int\n    name: str\n```\n\nwithout `emit_pydantic_models`\n\n```py\nimport dataclasses\n\n@dataclasses.dataclass()\nclass Author:\n    id: int\n    name: str\n```\n\n### Use `enum.StrEnum` for Enums\n\nOption: `emit_str_enum`\n\n`enum.StrEnum` was introduce in Python 3.11.\n\n`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.\n\nThis is convenient for type checking and validation, as well as for serialization and deserialization.\n\nBy 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.\n\nwith `emit_str_enum`\n\n```py\nclass Status(enum.StrEnum):\n    \"\"\"Venues can be either open or closed\"\"\"\n    OPEN = \"op!en\"\n    CLOSED = \"clo@sed\"\n```\n\nwithout `emit_str_enum` (current behavior)\n\n```py\nclass Status(str, enum.Enum):\n    \"\"\"Venues can be either open or closed\"\"\"\n    OPEN = \"op!en\"\n    CLOSED = \"clo@sed\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlc-dev%2Fsqlc-gen-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqlc-dev%2Fsqlc-gen-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlc-dev%2Fsqlc-gen-python/lists"}