{"id":25940509,"url":"https://github.com/pyflow/postmodel","last_synced_at":"2025-07-23T15:34:12.317Z","repository":{"id":41083707,"uuid":"237458090","full_name":"pyflow/postmodel","owner":"pyflow","description":"ORM library for Python 3.6+, asyncio. Provides Django ORM like API.","archived":false,"fork":false,"pushed_at":"2024-01-07T11:39:02.000Z","size":137,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-13T05:57:59.089Z","etag":null,"topics":["asyncio","asyncpg","django-orm","orm-framework","postgresql","redisql"],"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/pyflow.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,"zenodo":null}},"created_at":"2020-01-31T15:28:36.000Z","updated_at":"2024-04-08T19:07:43.000Z","dependencies_parsed_at":"2025-06-14T09:07:02.740Z","dependency_job_id":"88a55b79-c768-491a-a54a-661b5353f50c","html_url":"https://github.com/pyflow/postmodel","commit_stats":null,"previous_names":["zeaphoo/postmodel"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/pyflow/postmodel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyflow%2Fpostmodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyflow%2Fpostmodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyflow%2Fpostmodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyflow%2Fpostmodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyflow","download_url":"https://codeload.github.com/pyflow/postmodel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyflow%2Fpostmodel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265108519,"owners_count":23712472,"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":["asyncio","asyncpg","django-orm","orm-framework","postgresql","redisql"],"created_at":"2025-03-04T05:16:57.579Z","updated_at":"2025-07-23T15:34:12.226Z","avatar_url":"https://github.com/pyflow.png","language":"Python","readme":"# postmodel\n\n## Introduction\n\nPostmodel is an easy-to-use ``asyncio`` ORM *(Object Relational Mapper)* inspired by Django and Tortoise ORM.\n\nPostmodel provides 90% Django ORM like API, to ease the migration of developers wishing to switch to ``asyncio``.\n\nCurrently, Postmodel provides following features:\n\n* full active-record pattern\n* optimistic locking\n* 100% code coverage\n\n\nBut, it still have some limits:\n\n* only support Postgresql\n* no planing support SQLite, instead it will supports RediSQL\n* no support relation\n\n\nPostmodel is supported on CPython \u003e= 3.6 for PostgreSQL.\n\n\n## Getting Started\n\n### Installation\n\nYou have to install postmodel like this:\n\n```\npip install postmodel\n```\n\n### Quick Tutorial\n\nPrimary entity of postmodel is ``postmodel.models.Model``.\nYou can start writing models like this:\n\n\n```python\nfrom postmodel import models\n\nclass Book(models.Model):\n    id = models.IntField(pk=True)\n    name = models.TextField()\n    tag = models.CharField(max_length=120)\n\n    class Meta:\n        table = \"book_test\"\n\n    def __str__(self):\n        return self.name\n```\n\nAfter you defined all your models, postmodel needs you to init them, in order to create backward relations between models and match your db client with appropriate models.\n\nYou can do it like this:\n\n```python\nfrom postmodel import Postmodel\n\nasync def init():\n    # Here we connect to a PostgreSQL DB.\n    # also specify the app name of \"models\"\n    # which contain models from \"app.models\"\n    await Postmodel.init(\n        'postgres://postgres@localhost:54320/test_db',\n        modules= [__name__]\n    )\n    # Generate the schema\n    await Postmodel.generate_schemas()\n```\n\n\nHere we create connection to Postgres database, and then we discover \u0026 initialise models.\n\nPostmodel currently supports the following databases:\n\n* PostgreSQL (requires ``asyncpg``)\n\n``generate_schema`` generates the schema on an empty database. Postmodel generates schemas in safe mode by default which\nincludes the ``IF NOT EXISTS`` clause, so you may include it in your main code.\n\n\nAfter that you can start using your models:\n\n```python\n# Create instance by save\nbook = Book(id=1, name='Mastering postmdel', tag=\"orm\")\nawait book.save()\n\n# Or by .create()\nawait Book.create(id=2, name='Learning Python', tag=\"python\")\n\n# Query\n\nbooks = await Book.filter(tag=\"orm\").all()\nassert len(books) == 1\n```\n\n\n\n## Contributing\n\nPlease have a look at the `Contribution Guide \u003cdocs/CONTRIBUTING.md\u003e`_\n\n\n## License\n\nThis project is licensed under the MIT License - see the `LICENSE \u003cLICENSE\u003e`_ file for details","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyflow%2Fpostmodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyflow%2Fpostmodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyflow%2Fpostmodel/lists"}