{"id":13813527,"url":"https://github.com/snower/torpeewee","last_synced_at":"2025-03-21T01:30:47.079Z","repository":{"id":57476658,"uuid":"61872177","full_name":"snower/torpeewee","owner":"snower","description":"Tornado and asyncio asynchronous ORM by peewee","archived":false,"fork":false,"pushed_at":"2021-05-25T10:15:48.000Z","size":95,"stargazers_count":25,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-24T22:33:19.296Z","etag":null,"topics":["mysql","orm","peewee","postgresql","pymysql","tornado"],"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/snower.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}},"created_at":"2016-06-24T09:08:28.000Z","updated_at":"2024-08-01T04:59:45.000Z","dependencies_parsed_at":"2022-09-12T15:22:38.196Z","dependency_job_id":null,"html_url":"https://github.com/snower/torpeewee","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Ftorpeewee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Ftorpeewee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Ftorpeewee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Ftorpeewee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snower","download_url":"https://codeload.github.com/snower/torpeewee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244096756,"owners_count":20397474,"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":["mysql","orm","peewee","postgresql","pymysql","tornado"],"created_at":"2024-08-04T04:01:20.536Z","updated_at":"2025-03-21T01:30:46.823Z","avatar_url":"https://github.com/snower.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# torpeewee\n\n[![Build Status](https://travis-ci.org/snower/torpeewee.svg?branch=master)](https://travis-ci.org/snower/torpeewee)\n\nTornado and asyncio asynchronous ORM by peewee\n\n# About\n\ntorpeewee - Tornado and asyncio asynchronous ORM by peewee.\n\n# Installation\n\n    pip install torpeewee\n\n# Examples\n\n```python\n# -*- coding: utf-8 -*-\n# 16/7/7\n# create by: snower\n\nimport datetime\nimport asyncio\nfrom torpeewee import *\n\ndb = MySQLDatabase(\"test\", host=\"127.0.0.1\", port=3306, user=\"root\", passwd=\"123456\")\n\nclass BaseModel(Model):\n    class Meta:\n        database = db\n\nclass Test(BaseModel):\n    id = IntegerField(primary_key= True)\n    data = CharField(max_length=64, null=False)\n    count = IntegerField(default=0)\n    created_at = DateTimeField()\n    updated_at = DateTimeField()\n\n@db.transaction()\nasync def run_transaction(transaction):\n    async for i in Test.use(transaction).select().order_by(Test.id.desc()).limit(2):\n        print(i.id, i.data)\n\n    print(\"\")\n    t = await Test.use(transaction).create(data=\"test\", created_at=datetime.datetime.now(),\n                                           updated_at=datetime.datetime.now())\n    print(t.id, t.data)\n\n    async for i in Test.select().order_by(Test.id.desc()).limit(2):\n        print(i.id, i.data)\n\n    print(\"\")\n    for i in (await Test.use(transaction).select().order_by(Test.id.desc()).limit(2)):\n        print(i.id, i.data)\n\nasync def run():\n    t = await Test.select().where(Test.id == 5).first()\n    print(t)\n\n    c = await Test.select().where(Test.id \u003e 5).count()\n    print(c)\n\n    c = await Test.select().where(Test.id \u003e 5).group_by(Test.data).count()\n    print(c)\n\n    for i in (await Test.select().where(Test.id \u003e 5).where(Test.id\u003c=10)):\n        print(i.id, i.data)\n\n    async for i in Test.select().order_by(Test.id.desc()).limit(2):\n        print(i.id, i.data)\n    t = await Test.create(data = \"test\", created_at=datetime.datetime.now(), updated_at=datetime.datetime.now())\n    print(t.id, t.data)\n    async for i in Test.select().order_by(Test.id.desc()).limit(2):\n        print(i.id, i.data)\n\n    print(\"\")\n    print(\"\")\n\n    t = await Test.select().order_by(Test.id.desc()).limit(1)[0]\n    print(t.id, t.data, t.count)\n    t.count += 1\n    await t.save()\n    t = await Test.select().order_by(Test.id.desc()).limit(1)[0]\n    print(t.id, t.data, t.count)\n\n    print(\"\")\n    print(\"\")\n\n    async with await db.transaction() as transaction:\n        t = await Test.use(transaction).select().order_by(Test.id.desc()).limit(1)[0]\n        print(t.id, t.data, t.count)\n        t.count += 1\n        await t.use(transaction).save()\n\n        async for i in Test.use(transaction).select().order_by(Test.id.desc()).limit(2):\n            print(i.id, i.data)\n\n        print(\"\")\n        t = await Test.use(transaction).create(data=\"test\", created_at=datetime.datetime.now(), updated_at=datetime.datetime.now())\n        print(t.id, t.data)\n\n        async for i in Test.select().order_by(Test.id.desc()).limit(2):\n            print(i.id, i.data)\n\n        print(\"\")\n        for i in (await Test.use(transaction).select().order_by(Test.id.desc()).limit(2)):\n            print(i.id, i.data)\n\n    print(\"\")\n    print(\"\")\n\n    await run_transaction()\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(run())\n```\n\n# License\n\ntorpeewee uses the MIT license, see LICENSE file for the details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Ftorpeewee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnower%2Ftorpeewee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Ftorpeewee/lists"}