{"id":13424608,"url":"https://github.com/encode/orm","last_synced_at":"2025-05-14T20:09:41.882Z","repository":{"id":41380848,"uuid":"170355229","full_name":"encode/orm","owner":"encode","description":"An async ORM. 🗃","archived":false,"fork":false,"pushed_at":"2022-08-30T10:12:31.000Z","size":508,"stargazers_count":1791,"open_issues_count":21,"forks_count":99,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-05-14T20:09:41.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.encode.io/orm","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/encode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-12T16:51:31.000Z","updated_at":"2025-05-10T19:35:59.000Z","dependencies_parsed_at":"2022-07-19T01:47:45.923Z","dependency_job_id":null,"html_url":"https://github.com/encode/orm","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encode%2Form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/encode","download_url":"https://codeload.github.com/encode/orm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254219374,"owners_count":22034397,"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-31T00:00:56.965Z","updated_at":"2025-05-14T20:09:41.861Z","avatar_url":"https://github.com/encode.png","language":"Python","readme":"# ORM\n\n\u003cp\u003e\n\u003ca href=\"https://github.com/encode/orm/actions\"\u003e\n    \u003cimg src=\"https://github.com/encode/orm/workflows/Test%20Suite/badge.svg\" alt=\"Build Status\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/encode/orm\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/encode/orm/branch/master/graph/badge.svg\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/orm/\"\u003e\n    \u003cimg src=\"https://badge.fury.io/py/orm.svg\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\nThe `orm` package is an async ORM for Python, with support for Postgres,\nMySQL, and SQLite. ORM is built with:\n\n* [SQLAlchemy core][sqlalchemy-core] for query building.\n* [`databases`][databases] for cross-database async support.\n* [`typesystem`][typesystem] for data validation.\n\nBecause ORM is built on SQLAlchemy core, you can use Alembic to provide\ndatabase migrations.\n\n---\n\n**Documentation**: [https://www.encode.io/orm](https://www.encode.io/orm)\n\n---\n\n## Installation\n\n```shell\n$ pip install orm\n```\n\nYou can install the required database drivers with:\n\n```shell\n$ pip install orm[postgresql]\n$ pip install orm[mysql]\n$ pip install orm[sqlite]\n```\n\nDriver support is provided using one of [asyncpg][asyncpg], [aiomysql][aiomysql], or [aiosqlite][aiosqlite].\n\n---\n\n## Quickstart\n\n**Note**: Use `ipython` to try this from the console, since it supports `await`.\n\n```python\nimport databases\nimport orm\n\ndatabase = databases.Database(\"sqlite:///db.sqlite\")\nmodels = orm.ModelRegistry(database=database)\n\n\nclass Note(orm.Model):\n    tablename = \"notes\"\n    registry = models\n    fields = {\n        \"id\": orm.Integer(primary_key=True),\n        \"text\": orm.String(max_length=100),\n        \"completed\": orm.Boolean(default=False),\n    }\n\n# Create the tables\nawait models.create_all()\n\nawait Note.objects.create(text=\"Buy the groceries.\", completed=False)\n\nnote = await Note.objects.get(id=1)\nprint(note)\n# Note(id=1)\n```\n\n\u003cp align=\"center\"\u003e\u0026mdash; 🗃 \u0026mdash;\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003ci\u003eORM is \u003ca href=\"https://github.com/encode/orm/blob/master/LICENSE.md\"\u003eBSD licensed\u003c/a\u003e code. Designed \u0026 built in Brighton, England.\u003c/i\u003e\u003c/p\u003e\n\n[sqlalchemy-core]: https://docs.sqlalchemy.org/en/latest/core/\n[asyncpg]: https://github.com/MagicStack/asyncpg\n[aiomysql]: https://github.com/aio-libs/aiomysql\n[aiosqlite]: https://github.com/jreese/aiosqlite\n\n[databases]: https://github.com/encode/databases\n[typesystem]: https://github.com/encode/typesystem\n[typesystem-fields]: https://www.encode.io/typesystem/fields/\n","funding_links":[],"categories":["Third-Party Extensions","资源列表","Python","ORM","ORM [🔝](#readme)"],"sub_categories":["Databases","ORM"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencode%2Form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fencode%2Form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencode%2Form/lists"}