{ "info": { "author": "gwn", "author_email": "egeavunc@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Database" ], "description": "**Dead simple RDBMS handling library**\n\nhttps://github.com/gwn/dsql\n\nDead simple SQL generation and result handling library. Designed to work with\nPython DB API 2 compatible database connection objects.\n\nInstall with::\n\n pip install dsql\n\nYou can use `dsql` in two ways. First case is SQL statement generation::\n\n >>> from dsql import buildquery\n\n >>> buildquery('select',\n 'people',\n ['name', 'surname'],\n where=[{'age >': 30}],\n orderby='-age',\n dialect='postgresql')\n\n (\n 'SELECT \"name\", \"surname\" FROM \"people\" WHERE \"age\" > %s ORDER BY \"age\" DESC',\n [30]\n )\n\nSecond use case is to create a manager object that, in addition to generating\nyour statements, automatically executes them and handles the results for you::\n\n >>> import psycopg2\n >>> from psycopg2.extras import DictCursor\n >>> from dsql import makemanager\n\n >>> conn = psycopg2.connect(database='foo', cursor_factory=DictCursor)\n\n >>> db = dsql.makemanager(conn, dialect='postgresql')\n\n >>> itemiter = db.select('products', where=[{'color =': 'red'}])\n\n >>> itemiter.next()\n {\n 'id': 1,\n 'title': 'Shirt',\n 'color': 'red'\n }\n\n >>> db.insert('products', [{'title': 'Pants', 'color': 'green'},\n >>> {'title': 'Socks', 'color': 'yellow'}])\n [2, 3]\n\nNote that *it is required* to configure the connection to return DictCursors\ninstead of standard cursors, as in the example above.\n\nCheck out the reference section below for the documentation of the whole API.\n\n**Installation**::\n\n pip install dsql\n\n**Reference**\n\nCheck out::\n\n # Query Builder\n\n query, params = dsql.buildquery(operation, tablename,\n , ...\n dialect='standard')\n\n query, params = dsql.buildquery('select', tablename, fieldlist=[],\n where=[], groupby=[], having=[],\n orderby=[], limit=0, offset=0,\n dialect='standard')\n\n query, params = dsql.buildquery('insert', tablename, recordlist,\n dialect='standard')\n\n query, params = dsql.buildquery('update', tablename, updates, where=[],\n orderby=[], limit=0, offset=0,\n dialect='standard')\n\n query, params = dsql.buildquery('delete', tablename, where=[], orderby=[],\n dialect='standard')\n\n query, params = dsql.buildquery('raw', query, params)\n\n\n # Manager\n\n db = dsql.makemanager(dbapi2_compatible_connection_object,\n dialect='standard')\n\n itemiter = db.select(tablename, fieldlist=[], where=[], groupby=[],\n having=[], orderby=[], limit=1, offset=0, commit=True,\n dry_run=False, response_handler=None)\n\n list_of_inserted_ids = db.insert(tablename, recordlist, commit=True,\n dry_run=False, response_handler=None)\n\n number_of_affected_rows = db.update(tablename, updates, where=[],\n orderby=[], limit=0, offset=0,\n commit=True, dry_run=False,\n response_handler=None)\n\n number_of_affected_rows = db.delete(tablename, where=[], orderby=[],\n commit=True, dry_run=False,\n response_handler=None)\n\n mixed = db.raw(query, params, commit=True, dry_run=False,\n response_handler=None)\n # return value of this one depends on the type of query.\n\n related_connection_object = db.conn\n\n\nDocumentation of common parameters:\n\n*fieldlist*\n\nList of fields, such as `['name', 'age', 'occupation']`. Pass an empty list, or\nskip altogether, to get all the fields.\n\n*where*\n\nList of condition groups.\n\nEach condition group is a dict of predicate and value pairs, such as: `{'name\n=': 'John', 'age >': 30}`. Each pair is combined with `AND`, so this example is\ntranslated to the template `\"name\" = %s AND \"age\" >\n%s` and values of `['John', 30]`.\n\nCondition groups themselves are combined with `OR`, so the following `where`\nexpression::\n\n [{'name =': 'John', 'age >': 30}, {'occupation in': ['engineer', 'artist']}]\n\nTranslates to::\n\n WHERE (\"name\" = %s AND age > %s) OR (occupation IN (%s, %s))\n\nwith the values of: `['John', 30, 'engineer', 'artist']`\n\nAll standard comparison operators along with `LIKE`, `NOT LIKE`, `IN` and `NOT\nIN` are supported.\n\nIf you need to construct more complicated filters, try raw queries.\n\n*groupby*\n\nList of group fields, such as `['age', 'occupation']`\n\n*having*\n\nSame as `where`.\n\n*orderby*\n\nList of fields to order by. Add the `-` prefix to field names for descending\norder. Example: `['age', '-net_worth']`\n\n*limit*\n\nLimit as an integer, such as `50`.\n\n*offset*\n\nOffset as an integer, such as `200`.\n\n*dialect*\n\n`standard`, `postgresql` or `mysql`.\n\n*commit*\n\nAutomatically commit the query. If you choose not to commit, you can always get\nthe connection object from the manager object (via `manager.conn`) and make the\ncommit yourself when the time is right.\n\n*dry_run*\n\n`True` or `False`. If `True`, does not execute the query, but dump it to the\nstandard error for inspecting.\n\n*response_handler*\n\nBy default, the manager object handles the responses for you. It returns an\niterator of records for select calls, list of last inserted ids for insert\ncalls, and number of affected rows for others. In the cases you want to handle\nthe response yourself, you can pass your own `response_handler` whose arguments\nwill be the cursor object and the current dialect. Example::\n\n value_of_custom_handler = manager.select(tablename, limit=10,\n response_handler=custom_handler)\n\n\n**Examples**\n\nPosgreSQL with psycopg2::\n\n import psycopg2\n import psycopg2.extras\n import dsql\n\n conn = psycopg2.connect(host='localhost', user='root', database='lorem',\n cursor_factory=psycopg2.extras.DictCursor)\n\n db = dsql.makemanager(conn, dialect='postgresql')\n\n itemiter = db.select('products', ['id', 'name', 'description'])\n item = itemiter.next()\n print item['name']\n\n ...\n\nMySQL with MySQLdb::\n\n import MySQLdb\n import MySQLdb.cursors\n import dsql\n\n conn = MySQLdb.connect(host='localhost', user='root', db='lorem',\n cursorclass=MySQLdb.cursors.DictCursor)\n\n db = dsql.makemanager(conn, dialect='mysql')\n\n itemiter = db.select('products',\n ['id', 'name', 'description'],\n where=[{'status =': 'in stock'}])\n item = itemiter.next()\n print item['name']\n\n last_insert_ids = db.insert('products',\n [\n {\n 'name': 'foo',\n 'description': 'what a product!',\n }\n ])\n\n last_insert_ids = db.insert('products',\n [\n {\n 'name': 'foo',\n 'description': 'what a product!',\n }\n ],\n commit=False)\n db.conn.commit()\n\n affected_rowcount = db.update('products',\n {'name': 'lorem ipsum'},\n where=[{'id =': 888}])\n\n affected_rowcount = db.delete('products', where=[{'id =': 777}])", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gwn/dsql", "keywords": "sql db query builder simple", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dsql", "package_url": "https://pypi.org/project/dsql/", "platform": "", "project_url": "https://pypi.org/project/dsql/", "project_urls": { "Homepage": "https://github.com/gwn/dsql" }, "release_url": "https://pypi.org/project/dsql/0.4.1/", "requires_dist": null, "requires_python": "", "summary": "Dead simple RDBMS handling lib", "version": "0.4.1" }, "last_serial": 2956652, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "350cea4de813a7b08c8422d9a3246c6d", "sha256": "3e74050615339e09002f5697b6a33b7976d21ec7c08cacbe2ac6a801e17a9b28" }, "downloads": -1, "filename": "dsql-0.1.0.tar.gz", "has_sig": false, "md5_digest": "350cea4de813a7b08c8422d9a3246c6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3237, "upload_time": "2016-11-16T13:41:05", "url": "https://files.pythonhosted.org/packages/62/d9/880b27732d5f337c3d6d6babf1aa58a5d07df97d8d37997c31d39aa077e8/dsql-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "172be398f27dfa8a3bf8ffc276a4f99b", "sha256": "14e821b2d670db431c329286fdb3db96925b510d575e217a91898ad299748f66" }, "downloads": -1, "filename": "dsql-0.1.1.tar.gz", "has_sig": false, "md5_digest": "172be398f27dfa8a3bf8ffc276a4f99b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3122, "upload_time": "2016-11-16T14:31:03", "url": "https://files.pythonhosted.org/packages/90/1e/3a9bf76426a913fc82bf74acaa71b500cc9f68df829bfa2c8b94aad62984/dsql-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "407eeb9fd674118a48b26fbc94fe6dc8", "sha256": "7c876ea56e27e2d0e26192981ba73224552aff57d729388e34da12fca4350628" }, "downloads": -1, "filename": "dsql-0.1.2.tar.gz", "has_sig": false, "md5_digest": "407eeb9fd674118a48b26fbc94fe6dc8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3376, "upload_time": "2016-11-16T14:58:04", "url": "https://files.pythonhosted.org/packages/3d/84/593ba13dcadf6f991eb2832c6dc18c5b340487a560a76d2402bc8b408a3f/dsql-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "decfdc0285e53aa56d643021d81c14d1", "sha256": "f4faec4df61681f9e1ba48cd24c2385fdf500cc4541a75e0cd4cff8626c4d27e" }, "downloads": -1, "filename": "dsql-0.1.3.tar.gz", "has_sig": false, "md5_digest": "decfdc0285e53aa56d643021d81c14d1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5216, "upload_time": "2016-11-16T16:33:09", "url": "https://files.pythonhosted.org/packages/26/76/e96cead82ee339c66f678ebb526e004d3d3700c98f66b6eb2a93d268664a/dsql-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e54f487f7afc2bfeb777acc9152cdc1e", "sha256": "ac8e52bdbfa4147d78ae2604247e76e1211ff45ec013f48364478838cea08ba3" }, "downloads": -1, "filename": "dsql-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e54f487f7afc2bfeb777acc9152cdc1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4364, "upload_time": "2016-11-24T13:40:56", "url": "https://files.pythonhosted.org/packages/46/02/e1d948aaa98ee3e90219bee5e2441d30c31f3b23455d48b838f58dcbc1cd/dsql-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "3d49cb834096342e85e74c25e2a9d856", "sha256": "6e56e73e2385d3b3c3eb864c10e410ce9a2e438b1563af769008a891deb5e997" }, "downloads": -1, "filename": "dsql-0.2.1.tar.gz", "has_sig": false, "md5_digest": "3d49cb834096342e85e74c25e2a9d856", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4364, "upload_time": "2016-11-25T12:20:06", "url": "https://files.pythonhosted.org/packages/c1/44/cbe2fa4f0747ecf16293aa5ed199fa814b68d4fd2160956939602443d049/dsql-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "c050834768309cc0b9fbdf1b89bf8ed2", "sha256": "362a5acc33896d35b77d3c163fdb5c1cd5a1029e8de5556b70c87a565ababf73" }, "downloads": -1, "filename": "dsql-0.2.2.tar.gz", "has_sig": false, "md5_digest": "c050834768309cc0b9fbdf1b89bf8ed2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4392, "upload_time": "2016-11-25T12:26:45", "url": "https://files.pythonhosted.org/packages/c2/78/6cf7d96c74d8f75c810119427babb4c0f286bc341cd3a9cc2d42dcbc05c4/dsql-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "518f3a550459cc8248f865e980bcc575", "sha256": "db62f45ece127fdec6dd3809e7a217ba38ae9e9bd5893083796dda77395c8ffa" }, "downloads": -1, "filename": "dsql-0.2.3.tar.gz", "has_sig": false, "md5_digest": "518f3a550459cc8248f865e980bcc575", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4465, "upload_time": "2016-11-26T01:39:46", "url": "https://files.pythonhosted.org/packages/21/ba/b06fa4a21963671934786e8d3839c963aa7180cb34f7387b1e408b526998/dsql-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "49f06cb64f63fdb4729909a5b3861d51", "sha256": "b70efe2ec1bd661fc58cab060fc3d2a422f1f5250bfda48c265f2f15bd13d19d" }, "downloads": -1, "filename": "dsql-0.2.4.tar.gz", "has_sig": false, "md5_digest": "49f06cb64f63fdb4729909a5b3861d51", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4870, "upload_time": "2016-12-24T08:56:45", "url": "https://files.pythonhosted.org/packages/a5/c4/330c05a5b489d93d7a436a46284ee6ffaf0d680e91b6741ddab1c662a5c8/dsql-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "929d595a0a29e689b4a5866bc69c9ad4", "sha256": "79760c3e7f310d9d10add515de4466213f8b0fecf26cad22eb8ca1bb13189c41" }, "downloads": -1, "filename": "dsql-0.2.5.tar.gz", "has_sig": false, "md5_digest": "929d595a0a29e689b4a5866bc69c9ad4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4895, "upload_time": "2016-12-26T15:05:27", "url": "https://files.pythonhosted.org/packages/82/e5/c8065f8b8645f43563671d7e06863f6de1488df9ceaabce23a35f2ca9730/dsql-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "c74b213822a121970849cac24b3c1389", "sha256": "efc6d6354b51881bc9fc953edc032bbd04ab09e077366eb79fa95e2607aed859" }, "downloads": -1, "filename": "dsql-0.2.6.tar.gz", "has_sig": false, "md5_digest": "c74b213822a121970849cac24b3c1389", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4964, "upload_time": "2016-12-28T20:37:56", "url": "https://files.pythonhosted.org/packages/a3/41/a1a55f72ca35199b36d99268b50c7a0a7d1e0d9ffafbf6dbc7822e5ff073/dsql-0.2.6.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "5f3dcca66ab2f42d275af154b7e64497", "sha256": "00e08a14be2c3ed7284573a3afae67252cb9e816afef3c562839ead4f4142572" }, "downloads": -1, "filename": "dsql-0.3.0.tar.gz", "has_sig": false, "md5_digest": "5f3dcca66ab2f42d275af154b7e64497", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4943, "upload_time": "2016-12-28T21:00:11", "url": "https://files.pythonhosted.org/packages/c0/f5/43beca6eba40761fce83a4be3a4aca4accfd5accd9c35dfaf9378c321f7f/dsql-0.3.0.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "e5ca007bae6cb666427d318b0d931fca", "sha256": "f52027789548adec01b7802814bd14caab27f23beda41d47345710d23525e316" }, "downloads": -1, "filename": "dsql-0.3.2.tar.gz", "has_sig": false, "md5_digest": "e5ca007bae6cb666427d318b0d931fca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4932, "upload_time": "2017-01-01T14:33:02", "url": "https://files.pythonhosted.org/packages/12/5b/7b7fbcd9748a787e62447cda0954af7acbb091bb3b6ba33834cec13ea9ac/dsql-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "0f92431936d8b8d63cefa1b6e511516f", "sha256": "e5267d2e7dca5c7195267f9bf4e70c94faeb8deb75bfd9d91eb4d18f6a8f7d48" }, "downloads": -1, "filename": "dsql-0.3.3.tar.gz", "has_sig": false, "md5_digest": "0f92431936d8b8d63cefa1b6e511516f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4658, "upload_time": "2017-03-07T06:10:50", "url": "https://files.pythonhosted.org/packages/41/23/f8e7e84390431d26572b8be0e1011feb8c88d1132fbda04c1e4115da13ce/dsql-0.3.3.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "f624de55fe9e51d9d7a412a0193b4491", "sha256": "397e735ec6aaf1079792fc9a415f9460fa913e26042d998f48ba27ee27e1fd71" }, "downloads": -1, "filename": "dsql-0.4.1.tar.gz", "has_sig": false, "md5_digest": "f624de55fe9e51d9d7a412a0193b4491", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7317, "upload_time": "2017-06-17T18:23:05", "url": "https://files.pythonhosted.org/packages/6d/f7/1e27cb317428b88075027c58951bb468f4aa176f952f609d1bfa73a46aba/dsql-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f624de55fe9e51d9d7a412a0193b4491", "sha256": "397e735ec6aaf1079792fc9a415f9460fa913e26042d998f48ba27ee27e1fd71" }, "downloads": -1, "filename": "dsql-0.4.1.tar.gz", "has_sig": false, "md5_digest": "f624de55fe9e51d9d7a412a0193b4491", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7317, "upload_time": "2017-06-17T18:23:05", "url": "https://files.pythonhosted.org/packages/6d/f7/1e27cb317428b88075027c58951bb468f4aa176f952f609d1bfa73a46aba/dsql-0.4.1.tar.gz" } ] }