{ "info": { "author": "Zhichang Fu", "author_email": "fuzctc@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "![image](doc/crystaldb.jpg)\n\n\nCrystalDB\n========\nCrystalDB is a simple and small ORM. It has few concepts, making it easy to learn and intuitive to use.\n\n* a small, expressive ORM, and no need to provide a model, so it will not be difficult for the problem of sub-library or sub-tables. \n* python3.\n* need mysql-client or pymysql or mysql.connector.\n* currently only supports mysql.\n\n\nInstallation\n=========\nFrom PyPi:\n\n $ pip install crysyaldb\n\n\nBasic Usage\n=========\n* **Connect to the database:**\n\n ```python\n import crystaldb\n\n db_host = '127.0.0.1'\n db_port = 3306\n db_user = 'root'\n db_pass = '123'\n db_database = 'testdb'\n\n db_handle = crystaldb.database(\n dbn='mysql',\n host=db_host,\n port=db_port,\n user=db_user,\n passwd=db_pass,\n db=db_database,\n debug=True)\n ```\n\n* **Create table:** (Temporarily not supported, need to be completed by yourself) \n \n for example:\n \n ```python\n CREATE TABLE `user` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `gender` varchar(16) DEFAULT NULL,\n `name` varchar(16) DEFAULT NULL,\n `birthday` varchar(16) DEFAULT NULL,\n `age` int(11) unsigned DEFAULT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n ``` \n \n* **Create row:**\n ```python\n values = {\n 'gender': 'girl',\n 'name': 'xiaoli_orm',\n 'birthday': '1982-08-02',\n 'age': 36\n }\n result = db_handle.operator(\"user\").insert(**values)\n print(result) # ==> 1\n # If debug is True, the following log will be printed, time unit ms.\n # 0.3162 (1): INSERT INTO user (age, birthday, gender, name) VALUES (36, '1982-08-02', 'girl', 'xiaoli_orm')\n ```\n \n* **Querying:**\n ```python\n result = db_handle.select(\"user\", [\"name\", \"age\"]).filter(\n age=36, gender=\"girl\").query()\n print(result.__len__()) # count \n print(result) # \n for item in result:\n print(item) # \n print(item.name) # xiaowang\n # If debug is True, the following log will be printed, time unit ms.\n # 0.8579 (5): SELECT user.name, user.age FROM user WHERE user.age = 36 AND user.gender = 'girl'\n ```\n \n* **Update row:**\n ```python\n where = dict(name=\"xiaoli_orm\")\n values = {'gender': 'boy', 'birthday': '1981-08-02', 'age': 37}\n result = db_handle.operator(\"user\").update(where, **values)\n print(result) # 1\n # If debug is True, the following log will be printed, time unit ms.\n # 0.4399 (1): UPDATE user SET age = 37, birthday = '1981-08-02', gender = 'boy' WHERE name = 'xiaoli_orm';\n ```\n\n* **Delete row:**\n ```python\n where = dict(name=\"xiaoyu\", age=27)\n result = db_handle.operator(\"user\").delete(where)\n # If debug is True, the following log will be printed, time unit ms.\n # 0.3782 (1): DELETE FROM user WHERE age = 27 AND name = 'xiaoyu';\n ```\n \n* **Get Debug Queries:**\n ```python\n print(db_handle.get_debug_queries_info)\n # {'run_time': '0.8247', 'sql': \"SELECT user.name, user.age FROM user WHERE user.age = 36 AND user.gender = 'girl'\"}\n ``` \n\n\nDocumentation\n===============\n* [Insert](./doc/insert.md)\n* [Update](./doc/update.md)\n* [Querying](./doc/query.md)\n* [Delete](./doc/delete.md)\n\n\nLearning more\n===============\nCheck the documentation for more examples or read test cases in unit test code.\n\n\nChange Log\n===============\n[Change Log](https://github.com/CrystalSkyZ/crystaldb.py/releases)\n\n\nDiscussing\n===============\n* submit issue\n* email: fuzctc@gmail.com\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/CrystalSkyZ/crystaldb.py", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "crystaldb", "package_url": "https://pypi.org/project/crystaldb/", "platform": "", "project_url": "https://pypi.org/project/crystaldb/", "project_urls": { "Homepage": "https://github.com/CrystalSkyZ/crystaldb.py" }, "release_url": "https://pypi.org/project/crystaldb/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "CrystalDB is a simple and small ORM and no need to provide a model.", "version": "1.0.3" }, "last_serial": 4861206, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "52233dc74736251ff511ae75e5d81db5", "sha256": "269c9e8b75e63c70e6ab04622221490a9e04ce65ddc140299bdbb8658a049191" }, "downloads": -1, "filename": "crystaldb-1.0.0.tar.gz", "has_sig": false, "md5_digest": "52233dc74736251ff511ae75e5d81db5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16888, "upload_time": "2018-10-06T08:29:19", "url": "https://files.pythonhosted.org/packages/a5/a1/8da72c118906fe9f9aef5e50afbdb012913bbe9f03ca87fd02a26b81d973/crystaldb-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "3fc115291573678bf2522df6b2272a65", "sha256": "2e261bb3811d2ccb5a87f76aeda599fb9ca2ec8c1aad3fca279fa239286aa262" }, "downloads": -1, "filename": "crystaldb-1.0.1.tar.gz", "has_sig": false, "md5_digest": "3fc115291573678bf2522df6b2272a65", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20655, "upload_time": "2018-10-07T14:07:13", "url": "https://files.pythonhosted.org/packages/9e/fd/21d855b72a3b6c15b5922a0eb46c0bc18cf4ca178927634a713539fda01a/crystaldb-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "760f34179798190b415ae5810ef39630", "sha256": "c57020fe83308e353272ed9f16bec8f1b42d2b9be2092ebee98cad6d2919efa8" }, "downloads": -1, "filename": "crystaldb-1.0.2.tar.gz", "has_sig": false, "md5_digest": "760f34179798190b415ae5810ef39630", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20719, "upload_time": "2018-10-17T08:39:55", "url": "https://files.pythonhosted.org/packages/e0/7a/86220cea9e69659c38fe9642a8b96dd0f2ebcbad93cca6fda797d5859b72/crystaldb-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "84150209a550e7d3444584fea208e2d6", "sha256": "a26a675d6e7620cc1d3d5c9ff03bc30cad5a65361719292eb0f1ec47a94d018d" }, "downloads": -1, "filename": "crystaldb-1.0.3.tar.gz", "has_sig": false, "md5_digest": "84150209a550e7d3444584fea208e2d6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22734, "upload_time": "2019-02-24T14:57:53", "url": "https://files.pythonhosted.org/packages/60/e4/b8f9ccda011dd19d1988556232ef2b201e77d6c2d8aa1f1e3420ab007d3a/crystaldb-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "84150209a550e7d3444584fea208e2d6", "sha256": "a26a675d6e7620cc1d3d5c9ff03bc30cad5a65361719292eb0f1ec47a94d018d" }, "downloads": -1, "filename": "crystaldb-1.0.3.tar.gz", "has_sig": false, "md5_digest": "84150209a550e7d3444584fea208e2d6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22734, "upload_time": "2019-02-24T14:57:53", "url": "https://files.pythonhosted.org/packages/60/e4/b8f9ccda011dd19d1988556232ef2b201e77d6c2d8aa1f1e3420ab007d3a/crystaldb-1.0.3.tar.gz" } ] }