{ "info": { "author": "acthse", "author_email": "acthse@outlook.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "====\ntrod\n====\n\n.. image:: https://img.shields.io/pypi/v/trod.svg\n :target: https://pypi.python.org/pypi/trod\n\n.. image:: https://travis-ci.org/acthse/trod.svg?branch=master\n :target: https://travis-ci.org/acthse/trod\n\n.. image:: https://codecov.io/gh/acthse/trod/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/acthse/trod\n\n.. image:: https://img.shields.io/pypi/pyversions/trod.svg\n :target: https://img.shields.io/pypi/pyversions/trod.svg\n\n.. image:: https://img.shields.io/pypi/l/trod.svg\n :target: https://img.shields.io/pypi/l/trod.svg\n\n \n**Trod** is a very simple asynchronous Python ORM based on asyncio_. \nNow it only supports MySQL and uses aiomysql_ as the access 'driver' for the database.\n\n* Strictly, trod is not an ORM, it just working in an ORM-like mode. \n The objects in trod is completely isolated from the data in the database. \n It is only a Python object in memory, changing it does not affect the database. \n You must explicitly execute the commit request to the database.\n\n* Trod only uses model and object APIs to compose SQL statements and submit \n them to the database when executed. When loaded, the data is retrieved \n from the database and then packaged into objects.\n\n\nAbout\n-----\nThe author of trod (that's me \ud83d\ude0a) is a junior Pythoner, and trod has a lot of temporary \nsolutions to optimize and continue to add new features, this is just the beginning \ud83d\udcaa.\nI will continue later, and welcome your issues and pull requests.\n\n\nInstallation\n------------\n\n.. code-block:: console\n\n pip install trod\n\n\nBasic Example\n-------------\n\n.. code-block:: python\n\n import asyncio\n\n from trod import Trod, And, Auto\n from trod.types import field, index\n\n db = Trod()\n\n class User(db.Model):\n __table__ = 'user'\n __comment__ = 'user info'\n\n id = field.Bigint(length=20, unsigned=True, primary_key=True, comment='primary key')\n name = field.String(length=20, use_varchar=True, allow_null=False, comment='user name')\n password = field.String(length=45, use_varchar=True, comment='password')\n date = field.Datetime(comment='registration time')\n created_at = field.Timestamp(auto=Auto.on_create)\n updated_at = field.Timestamp(auto=Auto.on_update)\n\n name_idx = index.Key(column='name')\n\n async show_case():\n \"\"\" show some base case \"\"\"\n\n await db.bind('mysql://user:password@host:port/db')\n\n # create_table\n await User.create()\n\n # add a user\n user = User(id=1,name='name', password='123456')\n user_id = await User.add(user)\n print(user_id) # 1\n\n # get a user by id\n user = await User.get(user_id)\n print(user.password) # 123456\n\n # update user password\n await User.update(dict(password=654321), User.name == user.name)\n user = await User.get(user_id)\n print(user.password) # 654321\n\n # delete a user\n await User.remove(User.id == user.id) \n\n # query\n users = [\n User(id=2, name='zs', password='222222')\n User(id=3, name='ls', password='333333')\n ]\n await User.batch_add(users)\n query_users = await User.query().filter(\n User.id.in_([1,2,3])\n ).order_by(User.data).all()\n print(query_users) \n # [, , ] \n\n user = await User.query(User.password, User.name).filter(\n And(User.id.in_([1,2,3], User.name == 'ls'))\n ).first()\n print(user.password) # 333333\n\n await db.unbind()\n\n asyncio.get_event_loop().run_until_complete(show_case())\n\n\nRequirements\n------------\n\n* Python 3.6+\n* asyncio_\n\n.. _asyncio: https://docs.python.org/3/library/asyncio.html\n.. _aiomysql: https://github.com/aio-libs/aiomysql\n.. _QuickStart: https://github.com/acthse/trod/blob/master/docs/doc.md", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/acthse/trod", "keywords": "orm asyncio aiomysql python3 mysql", "license": "BSD license", "maintainer": "", "maintainer_email": "", "name": "trod", "package_url": "https://pypi.org/project/trod/", "platform": "", "project_url": "https://pypi.org/project/trod/", "project_urls": { "Homepage": "https://github.com/acthse/trod" }, "release_url": "https://pypi.org/project/trod/0.0.14/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Trod is a very simple asynchronous Python ORM based on asyncio", "version": "0.0.14" }, "last_serial": 5318623, "releases": { "0.0.11": [ { "comment_text": "", "digests": { "md5": "4cc200d12bdf577a1bf0bca8fdc4722f", "sha256": "d5808da96629a94f708a690c054eb3f9028f36a7384bd16c9405b6ce6b03260d" }, "downloads": -1, "filename": "trod-0.0.11-py3-none-any.whl", "has_sig": false, "md5_digest": "4cc200d12bdf577a1bf0bca8fdc4722f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 26513, "upload_time": "2018-12-30T09:17:43", "url": "https://files.pythonhosted.org/packages/a4/01/dce4ed826c6f52e36a35e7747e816607532c7f2cf9bb1b61642c64869cda/trod-0.0.11-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d5caa8ab01574fd3521579fd3f03af82", "sha256": "1a91dda171d3a278de1ab8c3c445298c127f46b01f69a262e03734e8c2bf18ac" }, "downloads": -1, "filename": "trod-0.0.11.tar.gz", "has_sig": false, "md5_digest": "d5caa8ab01574fd3521579fd3f03af82", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 23049, "upload_time": "2018-12-30T09:17:45", "url": "https://files.pythonhosted.org/packages/95/b0/2ee7756bcc0b501e75a7dc2a6fed2449f6720b6b02070c468c90354d27c2/trod-0.0.11.tar.gz" } ], "0.0.12": [ { "comment_text": "", "digests": { "md5": "e10800a868ecd6c96ec7842030e7052b", "sha256": "e9b22424ad0b1199858387672f39ef38cbe110c6cfdfc7e455466d8d248b133d" }, "downloads": -1, "filename": "trod-0.0.12-py3-none-any.whl", "has_sig": false, "md5_digest": "e10800a868ecd6c96ec7842030e7052b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 26568, "upload_time": "2019-01-15T13:14:50", "url": "https://files.pythonhosted.org/packages/5b/76/1c0a0862d9a583cec038a5f7272d1efa3695ede2642d2b609abdf753dc3e/trod-0.0.12-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9415ab62aff2b1de7c0ad370f46ee74b", "sha256": "716a423e324d4774f93323a9d9abf6affa64867069afc2298e0a89fa23def9a1" }, "downloads": -1, "filename": "trod-0.0.12.tar.gz", "has_sig": false, "md5_digest": "9415ab62aff2b1de7c0ad370f46ee74b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 23133, "upload_time": "2019-01-15T13:14:52", "url": "https://files.pythonhosted.org/packages/20/d3/714371c8dba7500ec70baff3c3eed733dfe403e5581c9894e9083bbd5c9b/trod-0.0.12.tar.gz" } ], "0.0.13": [ { "comment_text": "", "digests": { "md5": "94707fc7fe64c0999cefcd4121efd6e3", "sha256": "c46562ce2d68a80d7f01abae6a0816af1f8a3015870ec226c8bed4cec94d2353" }, "downloads": -1, "filename": "trod-0.0.13.tar.gz", "has_sig": false, "md5_digest": "94707fc7fe64c0999cefcd4121efd6e3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 23196, "upload_time": "2019-05-26T11:11:29", "url": "https://files.pythonhosted.org/packages/e6/bf/9fe69439076d56acff13a1fc4ec0352059d8fcf705ecc72d205ba5047cd1/trod-0.0.13.tar.gz" } ], "0.0.14": [ { "comment_text": "", "digests": { "md5": "7561db1a11974f94ce0a21aaf86b0ed2", "sha256": "e82dc308fb2c0af84a8bae64a3846cffcc6fdee0578478b4a584cd68e7187757" }, "downloads": -1, "filename": "trod-0.0.14.tar.gz", "has_sig": false, "md5_digest": "7561db1a11974f94ce0a21aaf86b0ed2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 23162, "upload_time": "2019-05-26T11:24:47", "url": "https://files.pythonhosted.org/packages/7e/e4/16f24fe681a9203cd59bd446102103f21d6d99f716b737c96a393441cbc4/trod-0.0.14.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7561db1a11974f94ce0a21aaf86b0ed2", "sha256": "e82dc308fb2c0af84a8bae64a3846cffcc6fdee0578478b4a584cd68e7187757" }, "downloads": -1, "filename": "trod-0.0.14.tar.gz", "has_sig": false, "md5_digest": "7561db1a11974f94ce0a21aaf86b0ed2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 23162, "upload_time": "2019-05-26T11:24:47", "url": "https://files.pythonhosted.org/packages/7e/e4/16f24fe681a9203cd59bd446102103f21d6d99f716b737c96a393441cbc4/trod-0.0.14.tar.gz" } ] }