{ "info": { "author": "James", "author_email": "xxx_828@126.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Database" ], "description": "Welcome to saiorm /sa\u026a\u0254:m/,\u585e\u7fc1\n===============================\n\nSaiorm is a simple library for accessing database.\nIt will take you have a very easy way to use SQL database.\n\n.. We want it to be an asynchronous framework,but not now.\n\n**Method:**\n\n- Method **insert, select, update, delete, execute, executemany, increase, decrease** should be executed **finally**,they will take effect immediately.\n\n- Method **last_sql** return the latest executed sql.\n\n- Method **get_fields_name** get a list of all fields name, cache them by default.\n\n- Method **where** could be dict or str type. **IN** require a string or a sequence with str type.\n\n- Method **select** and **get** return data only.\n\n- Method **update**, **delete**, **execute** return a dict,including lastrowid, rowcount, rownumber, sql.\n\n- Various method join,should use string param for method join and method where.\n\n**ATTENTION**\n\n1. Saiorm does not convert value type in condition(limit,order_by,group_by,\nvarious join etc.),method where not convert value type in native functions and IN.\nIf you want to use the values passed from user,you must check them,\nbecause it's easily to triggering injection vulnerability.\n\n2. Saiorm require python3 and pymysql.\n\n3. Support MySQL only,you can inherit from saiorm.base.BaseDB to support other types\nof database with the same API,like siaorm.MySQL.ChainDB.\n\n4. You can add \"`\" as a prefix to set the field to native function in method select and update.\n\nInitialization\n~~~~~~~~~~~~~~\n\n.. code:: python\n\n import saiorm\n\n DB = saiorm.init() # with no table name prefix\n # DB = saiorm.init(table_name_prefix=\"abc_\") # with table name prefix\n DB.connect({\"host\": \"\", \"port\": 3306, \"database\": \"\", \"user\": \"\", \"password\": \"\"})\n table = DB.table(\"xxx\")\n\nUsage for calling mysql function only\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n DB.select(\"`NOW()\")\n DB.select(\"`SUM(1+2)\")\n\nwill transform to SQL\n\n.. code:: sql\n\n SELECT NOW();\n SELECT SUM(1+2);\n\nUsage for select and get\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n1. select will return all data\n\n2. get will modify _limit attribute automatically,then return the latest line only.\n**If you call get method, limit method will be overwrited**\n\n3. select and get receive a fields param.\n\n.. code:: python\n\n # select all fields\n table.select()\n\n # get the latest line\n table.order_by(\"id DESC\").get()\n\n # kinds of params in where\n table.where({\n \"a\": 1,\n \"b\": (\"BETWEEN\", \"1\", \"2\"),\n \"c\": (\"`ABS(?)\", \"2\"),\n \"d\": (\"!=\", 0),\n \"e\": (\"IN\", \"1,2,3\"),\n \"f\": \"`NOW()\",\n }).select(\"e,f\")\n\nwill transform to SQL\n\n.. code:: sql\n\n SELECT * FROM xxx ;\n SELECT * FROM xxx ORDER BY id DESC LIMIT 1;\n SELECT e,f FROM xxx WHERE a=1 AND b BETWEEN '1' AND '2' AND c=ABS(2) AND d!=0 AND e IN (1,2,3) AND f=NOW() ;\n\nUsage for update\n~~~~~~~~~~~~~~~~\n\nIf you want use native function,you can pass a tuple.\n\n.. code:: python\n\n table.where({\n \"a\": (\"IN\", [\"1\", \"2\", \"3\"]),\n \"b\": (\"`ABS(?)\", \"2\"),\n }).update({\n \"c\": \"`ABS(2)\",\n \"d\": (\"`ABS(?)\", 3),\n \"e\": \"2\",\n })\n\nwill transform to SQL\n\n.. code:: sql\n\n UPDATE xxx SET c=ABS(2),d=ABS(3),e='2' WHERE a IN (1,2,3) AND b=ABS(2) ;\n\n\nUsage for insert\n~~~~~~~~~~~~~~~~\n\ninsert function support two kinds of data\n\n.. code:: python\n\n # use natural dict\n table.insert({\n \"a\": \"1\",\n \"b\": \"2\",\n })\n\n # use split dict\n table.insert({\n \"fields\": [\"a\", \"b\"],\n \"values\": [\"1\", \"2\"],\n })\n\n # use natural dict in list, SQL will in one line\n table.insert_many([{\n \"a\": \"1\",\n \"b\": \"2\",\n }, {\n \"a\": \"3\",\n \"b\": \"4\",\n }, {\n \"a\": \"5\",\n \"b\": \"6\",\n }])\n\n # use split dict in list, SQL will in one line\n table.insert_many({\n \"fields\": [\"a\", \"b\"],\n \"values\": [\n [\"1\", \"2\"],\n [\"3\", \"4\"],\n [\"5\", \"6\"]\n ]\n })\n\n\nwill transform to SQL\n\n.. code:: sql\n\n INSERT INTO xxx (a,b) VALUES ('1','2');\n INSERT INTO xxx (a,b) VALUES ('1','2');\n INSERT INTO xxx (a,b) VALUES ('1','2'),('3','4'),('5','6');\n INSERT INTO xxx (a,b) VALUES ('1','2'),('3','4'),('5','6');\n\nIf use split dict,key fields is not necessary,it will insert by the order of table struct.\n\nUsage for delete\n~~~~~~~~~~~~~~~~\n\nBy default, **delete** must have **where** condition,or you can pass strict=False when initialization.\n\n.. code:: python\n\n table.where({\n \"a\": \"1\",\n \"b\": \"2\",\n \"c\": (\"`ABS(?)\", \"2\"),\n }).delete()\n\n table.delete() # will not be executed, or set strict=False when initialization\n\nwill transform to SQL\n\n.. code:: sql\n\n DELETE FROM xxx WHERE a='1' AND b='2' AND c=ABS(2) ;\n DELETE FROM xxx ;\n\nUsage for increase\n~~~~~~~~~~~~~~~~~~\n\nNumerical field increase\n\n.. code:: python\n\n table.increase(\"a\", 1)\n\nwill transform to SQL\n\n.. code:: sql\n\n UPDATE xxx SET a=a+1\n\nUsage for decrease\n~~~~~~~~~~~~~~~~~~\n\nNumerical field decrease\n\n.. code:: python\n\n table.decrease(\"a\", 1)\n\nwill transform to SQL\n\n.. code:: sql\n\n UPDATE xxx SET a=a-1\n\nwhere condition\n~~~~~~~~~~~~~~~\n\n.. code:: python\n\n table.where({\n \"a\": 1,\n \"b\": (\"BETWEEN\", \"1\", \"2\"),\n \"c\": (\"ABS(?)\", \"2\"),\n \"d\": (\"!=\", 0),\n \"e\": (\"IN\", \"1,2,3\"),\n \"f\": \"NOW()\",\n }).select(\"e,f\")\n\n- must check param to prevent injection vulnerabilities.\n\n- when calling native mysql function the param placeholder could be ?.\n\n- condition will be equals to value,or pass a tuple or list, and set the first item to change it.\n\n- use IN or BETWEEN should pass a tuple or list.\n\n- pass string type is allowed,you should join param into this string.\n\nMethod Shorthand\n~~~~~~~~~~~~~~~~\n\n| t equals to table\n| w equals to where\n| ob equals to order_by\n| l equals to limit\n| gb equals to group_by\n| j equals to join\n| ij equals to inner_join\n| lj equals to left_join\n| rj equals to right_join\n| s equals to select\n| i equals to insert\n| im equals to insert_many\n| u equals to update\n| d equals to delete\n| inc equals to increase\n| dec equals to decrease", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/weihaipy/saiorm", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "saiorm", "package_url": "https://pypi.org/project/saiorm/", "platform": "", "project_url": "https://pypi.org/project/saiorm/", "project_urls": { "Homepage": "https://github.com/weihaipy/saiorm" }, "release_url": "https://pypi.org/project/saiorm/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "Saiorm is a simple ORM.", "version": "0.0.3" }, "last_serial": 3660756, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "f3f7e763dfec137c73787e70ff174d70", "sha256": "1401bb0e6fad9db7eb6d230339a077de238a22b57e120442f127d34611308fd2" }, "downloads": -1, "filename": "saiorm-0.0.1.tar.gz", "has_sig": false, "md5_digest": "f3f7e763dfec137c73787e70ff174d70", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13243, "upload_time": "2018-03-12T05:02:38", "url": "https://files.pythonhosted.org/packages/4f/5d/6fc906664431b681af8a90a3b4643f79509d47cabca70562258633a29212/saiorm-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "e8048dfd71602bb3446ad72baf5ed9af", "sha256": "9ac695adb1b7a85b96e41e459d7edba62dd3ce59ceae1ac4324b36b4b652a294" }, "downloads": -1, "filename": "saiorm-0.0.2.tar.gz", "has_sig": false, "md5_digest": "e8048dfd71602bb3446ad72baf5ed9af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14335, "upload_time": "2018-03-12T08:50:18", "url": "https://files.pythonhosted.org/packages/b2/01/281bb5257530480fb10a4b00c8b61cfe0f8a8a23a5a80ff0256cb94132ca/saiorm-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "d15296c66a114940a549dd9000e49660", "sha256": "d593e7209a7cc9033c19466d81e159926bff51f04fd65085d6b6322df4954f13" }, "downloads": -1, "filename": "saiorm-0.0.3.tar.gz", "has_sig": false, "md5_digest": "d15296c66a114940a549dd9000e49660", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14339, "upload_time": "2018-03-12T09:08:29", "url": "https://files.pythonhosted.org/packages/4a/49/c5bab8526aca488e35c54f2f103078dd5b30d5a3c09b55c60f9f72a20c0e/saiorm-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d15296c66a114940a549dd9000e49660", "sha256": "d593e7209a7cc9033c19466d81e159926bff51f04fd65085d6b6322df4954f13" }, "downloads": -1, "filename": "saiorm-0.0.3.tar.gz", "has_sig": false, "md5_digest": "d15296c66a114940a549dd9000e49660", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14339, "upload_time": "2018-03-12T09:08:29", "url": "https://files.pythonhosted.org/packages/4a/49/c5bab8526aca488e35c54f2f103078dd5b30d5a3c09b55c60f9f72a20c0e/saiorm-0.0.3.tar.gz" } ] }