{ "info": { "author": "haokuan", "author_email": "jingdaohao@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# dbskit\n[![Build Status](https://api.travis-ci.org/listen-lavender/dbskit.svg?branch=master)](https://api.travis-ci.org/listen-lavender/dbskit)\n\ndbskit\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5c01\u88c5\u4e86mongo\uff0cmysql\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u5de5\u5177\u96c6\uff0c\u652f\u6301\u7ebf\u7a0b\u548c\u534f\u7a0b\uff1borm\u7684mongo\u548cmysql\u64cd\u4f5c\u662f\u4e00\u81f4\u7684\uff0c\u90fd\u9075\u5faamong\u8bed\u6cd5\uff0c\u4f8b\u5982query(select id, name from user where id = 2)\u9700\u5199\u6210query({'id':2}, {'id':1, 'name':1})\uff0c\u64cd\u4f5c\u7684\u4e00\u81f4\u5c31\u53ef\u4ee5\u8f7b\u677e\u5207\u6362\u9879\u76ee\u7684\u6570\u636e\u5e93\uff0c\u53ea\u9700\u8981\u4fee\u6539\u6570\u636e\u5e93\u7684\u914d\u7f6e\u8fde\u63a5\u5c31\u53ef\u4ee5\u4e86\uff0c\u5f53\u7136sqlalchemy\u8fd9\u79cd\u5927\u578b\u7684orm\u5df2\u7ecf\u652f\u6301\u7684\u5f88\u597d\u4e86\uff0c\u4f46\u662fdbskit\u5bf9\u4e8e\u5c0f\u578b\u9879\u76ee\u66f4\u76f4\u89c2\uff0c\u7b80\u5355\uff0c\u65b9\u4fbf\u63a7\u5236.\n\nMaybe you have other choice to cross platform, like sqlalchemy, but dbskit is easy to use and control.\n\n## mysql (mongo syntax operation)\n\n> - \u652f\u6301\u7ebf(\u534f)\u7a0b\u6c60\n> - \u57fa\u672c\u7684orm\n\n## mongo\n\n> - \u652f\u6301mongo\u7684bulk\u64cd\u4f5c\n> - \u57fa\u672c\u7684orm\n\n# Getting started\n\nHere is a simple example orm operation for Dbskit:\n\n````python\n\n # coding=utf-8\n from dbskit.mysql import transfer\n from dbskit.mysql.orm import *\n from dbskit.mysql.suit import dbpc, withMysql\n\n class MarkModel(Model):\n\n def __init__(self, **attributes):\n self.__mappings__['create_time'] = DatetimeField(ddl='datetime')\n self.__mappings__['update_time'] = DatetimeField(ddl='datetime')\n self.__mappings__['tid'] = IntField(ddl='int')\n attributes['create_time'] = attributes.get('create_time', datetime.datetime.now())\n attributes['update_time'] = attributes.get('update_time', datetime.datetime.now())\n for key in self.__mappings__:\n if not key in attributes:\n raise Exception('Need field %s. ' % key)\n attributes[key] = self.__mappings__[key].check_value(attributes[key])\n super(Model, self).__init__(**attributes)\n\n def __setstate__(self, state):\n self.__dict__ = state\n\n def __getstate__(self):\n return self.__dict__\n\n\n def initDB():\n dbpc.addDB('test', 20, host='localhost',\n port=3306,\n user='root',\n passwd='',\n db='pholcus',\n charset='utf8',\n use_unicode=False,\n override=False)\n dbpc.addDB('test', 20, host='localhost',\n port=3306,\n user='root',\n passwd='',\n db='pholcus',\n charset='utf8',\n use_unicode=False,\n override=False)\n\n '''\n @comment('\u4ee3\u7406\u6570\u636e')\n '''\n class Proxy(MarkModel):\n __table__ = 'grab_proxy'\n ip = StrField(ddl='str', unique='daili')\n port = IntField(ddl='int(5)', unique='daili')\n location = StrField(ddl='varchar(30)')\n safetype = StrField(ddl='varchar(30)')\n protocol = StrField(ddl='varchar(30)')\n refspeed = FloatField(ddl='float')\n usespeed = FloatField(ddl='float')\n usenum = IntField(ddl='int(10)')\n status = IntField(ddl='tinyint(1)')\n\n\n initDB()\n\n @withMysql('test', resutype='DICT', autocommit=True)\n def test():\n print transfer({\"$or\" : [{\"id_num\" : {\"$mod\" : [5, 1]}}, {\"winner\" : True}]}, grand=None, parent='', index=index, condition=condition)\n a = Proxy.queryOne({'ip':'110.52.221.27'}, {'ip':1, 'port':1, 'usenum':1})\n print a\n Proxy.update({'ip':'110.52.221.27'}, {'$inc':{'port':1}, '$set':{'usenum':2}})\n a = Proxy.queryOne({'ip':'110.52.221.27'}, {'ip':1, 'port':1, 'usenum':1})\n print a\n\n\n if __name__ == '__main__':\n test()\n````\n\n## Installation\n\nTo install dbskit, simply:\n\n````bash\n\n $ pip install dbskit\n \u2728\ud83c\udf70\u2728\n````\n\nSatisfaction, guaranteed.\n\n## Documentation\n\n TODO\n\n## Discussion and support\n\nReport bugs on the *GitHub issue tracker ", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "dbskit", "package_url": "https://pypi.org/project/dbskit/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dbskit/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/listen-lavender/dbskit" }, "release_url": "https://pypi.org/project/dbskit/1.1.2/", "requires_dist": null, "requires_python": null, "summary": "wecatch dbskit", "version": "1.1.2" }, "last_serial": 2267848, "releases": { "1.1.0": [ { "comment_text": "", "digests": { "md5": "eee2124c6938336260ace387c42c9694", "sha256": "f8fcda9b5becb10c7c5e78c16ee35499d8fb4fef0c6150d00c6294734ba09f11" }, "downloads": -1, "filename": "dbskit-1.1.0.tar.gz", "has_sig": false, "md5_digest": "eee2124c6938336260ace387c42c9694", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14759, "upload_time": "2016-06-24T10:34:44", "url": "https://files.pythonhosted.org/packages/9a/7d/0a62f4adb5795ebd2931dd973685b4691f6a003b68d2339e364ca3f853b6/dbskit-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "17fb9253a269804c5e94d3f660e6dbb5", "sha256": "8a9aadb1450a760fb829fd95967f662f83152f9874d40d4300f3899d590c2514" }, "downloads": -1, "filename": "dbskit-1.1.1.tar.gz", "has_sig": false, "md5_digest": "17fb9253a269804c5e94d3f660e6dbb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14753, "upload_time": "2016-07-26T00:31:11", "url": "https://files.pythonhosted.org/packages/77/da/aba0fee150bd1f9d2ed2832b257a9c54339bb923e30addbb42b3e16e4ab2/dbskit-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "f1e2e44bd1f83dcf883b4868782aa24f", "sha256": "450ba90349f92c1275c3f8e9b8e11c64de65c33042d854fe1a5e6d3f43be734c" }, "downloads": -1, "filename": "dbskit-1.1.2.tar.gz", "has_sig": false, "md5_digest": "f1e2e44bd1f83dcf883b4868782aa24f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14761, "upload_time": "2016-08-08T03:29:52", "url": "https://files.pythonhosted.org/packages/a7/64/1f8286d33f42f297665247e43f481c85122419b12f48e72cac844962282e/dbskit-1.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f1e2e44bd1f83dcf883b4868782aa24f", "sha256": "450ba90349f92c1275c3f8e9b8e11c64de65c33042d854fe1a5e6d3f43be734c" }, "downloads": -1, "filename": "dbskit-1.1.2.tar.gz", "has_sig": false, "md5_digest": "f1e2e44bd1f83dcf883b4868782aa24f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14761, "upload_time": "2016-08-08T03:29:52", "url": "https://files.pythonhosted.org/packages/a7/64/1f8286d33f42f297665247e43f481c85122419b12f48e72cac844962282e/dbskit-1.1.2.tar.gz" } ] }