{ "info": { "author": "Outernet Inc", "author_email": "branko@outernet.is", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Topic :: Utilities" ], "description": "======\nsqlize\n======\n\nSqlize is a SQL query builder for Python. It's main goals are:\n\n- speed: because fast is good\n- transparency: do not hide the true nature of SQL\n- mutability: we should be able to mutate the query\n\nThis library is primarily developed for use with SQLite and no efforts have\nbeen invested into testing or using with other database backends.\n\nInstallation\n============\n\nSqlize can be installed using ``pip`` or ``easy_install`` as usual::\n\n pip install sqlize\n\n\nIntroduction (quick tutorial)\n=============================\n\nThis section will provide a brief introduction to sqlize. The examples are all\ndoctested, so rest assured that they work as expected.\n\nThe basic concept is to instantiate an object representing some type of query,\noptionally manipulate attributes on it to fine-tune the clauses, and finally\nconvert the query into SQL string by coercing it into string.\n\nNote that the queries are meant to be used with placeholder values, and **no\nquoting is performed by sqlize**. The generated SQL strings are intended to be\nused with ``sqlite3.Cursor.execute()``, and similar methods.\n\nA basic select looks like this::\n\n >>> import sqlize as sql\n >>> q = sql.Select('*', sets='foo')\n\nNote that we call tables 'sets' to avoid the clash with Python's ``from``\nkeyword.\n\nTo convert the query to SQL, we simply coerce it into a ``str``::\n\n >>> str(q)\n 'SELECT * FROM foo;'\n\nYou can select multiple things::\n\n >>> str(sql.Select(['foo', 'bar'], sets='foo'))\n 'SELECT foo, bar FROM foo;'\n\nYou can also select from mutliple tables::\n\n >>> str(sql.Select('*', sets=['foo', 'bar']))\n 'SELECT * FROM foo , bar;'\n\n\nIf you want to restrict your select, all common clauses are available::\n\n >>> str(sql.Select('*', ['foo', 'bar'], where='a = ?', group='foo',\n ... order='-bar', limit=10, offset=20))\n 'SELECT * FROM foo , bar WHERE a = ? GROUP BY foo ORDER BY bar DESC LIMIT 10 OFFSET 20;'\n\n\nSo far it looks like a rather complicated way of writing SQL. The real power,\nthough, comes from the fact that every aspect of the query object can be\ntweaked.::\n\n >>> q = sql.Select()\n >>> str(q)\n 'SELECT *;'\n >>> q.what = 'foo'\n >>> q.sets = 'this'\n >>> q.sets.join('other', sql.INNER)\n \n >>> q.where = 'bar = ?'\n >>> q.limit = 2\n >>> str(q)\n 'SELECT foo FROM this INNER JOIN other WHERE bar = ? LIMIT 2;'\n\nNow let's take a look at individual clauses. \n\nThe ``where`` attribute is represented by a ``sqlize.builder.Where`` object,\nwhich supports a few handy operators for adding conditions::\n\n >>> q = sql.Select()\n >>> q.where = 'foo = ?'\n >>> q.where &= 'bar = ?'\n >>> q.where |= 'foo = bar'\n >>> str(q)\n 'SELECT * WHERE foo = ? AND bar = ? OR foo = bar;'\n\nThe ``&=`` and ``|=`` have method aliases. Main advantage is that methods are\nchainable. The above example can be rewritten as::\n\n >>> q = sql.Select()\n >>> q.where = 'foo = ?'\n >>> q.where.and_('bar = ?').or_('foo = bar')\n \n >>> str(q)\n 'SELECT * WHERE foo = ? AND bar = ? OR foo = bar;'\n\nNote the underscore. We can't use method names that look like built-in\noperators.\n\nThe ``sets`` attribute is represented by a ``sqlize.builder.From`` object. It\nhas a few utility methods which you can use to add and join other tables::\n\n >>> q = sql.Select()\n >>> q.sets = 'foo'\n >>> q.sets.append('bar')\n \n >>> str(q)\n 'SELECT * FROM foo , bar;'\n\n >>> q = sql.Select()\n >>> q.sets = 'foo'\n >>> q.sets.join('bar', sql.NATURAL)\n \n >>> str(q)\n 'SELECT * FROM foo NATURAL JOIN bar;'\n\nThere is no direct support for aggregates. Instead, you write raw SQL.::\n\n >>> q = sql.Select('COUNT(*) as count', sets='foo', group='bar')\n >>> str(q)\n 'SELECT COUNT(*) as count FROM foo GROUP BY bar;'\n\nThis is intentional. We wanted sqlize to be as true to SQL as possible, and not\nget in your way.\n\nApart from selecting, sqlize supports inserts, updates, deletion, and\nreplacement.\n\nInserts look like this::\n\n >>> q = sql.Insert('foo', '?, ?, ?')\n >>> str(q)\n 'INSERT INTO foo VALUES (?, ?, ?);'\n\nYou can also specify columns::\n\n >>> q = sql.Insert('foo', '?, ?, ?', ('foo', 'bar', 'baz'))\n >>> str(q)\n 'INSERT INTO foo (foo, bar, baz) VALUES (?, ?, ?);'\n\nIf you omit the values, the query will contain named placeholders::\n\n >>> q = sql.Insert('foo', cols=('foo', 'bar', 'baz'))\n >>> str(q)\n 'INSERT INTO foo (foo, bar, baz) VALUES (:foo, :bar, :baz);'\n\nReplacing is exactly the same as inserting, but uses ``Replace`` class\ninstead::\n\n >>> q = sql.Replace('foo', '?, ?, ?')\n >>> str(q)\n 'REPLACE INTO foo VALUES (?, ?, ?);'\n\nThe update query looks like this::\n\n >>> q = sql.Update('foo', 'bar = ?', baz='?')\n >>> str(q)\n 'UPDATE foo SET baz = ? WHERE bar = ?;'\n\nThe second argument is the same as ``where`` in ``Select()``. It can be\nmodified after initialization::\n\n >>> q = sql.Update('foo', baz='?')\n >>> q.where &= 'foo = ?'\n >>> q.where |= 'bar = ?'\n >>> str(q)\n 'UPDATE foo SET baz = ? WHERE foo = ? OR bar = ?;'\n\nAny keyword arguments passed to ``Update()`` will be converted to ``SET``\nclauses.\n\nDeleting rows can be accomplished using the ``Delete()`` class.::\n\n >>> q = sql.Delete('foo', 'bar = ?')\n >>> str(q)\n 'DELETE FROM foo WHERE bar = ?;'\n\nAs with ``Update()``, the second argument is a ``where`` clause, and can be\nmanipulated.\n\nMore docs, please!\n==================\n\nUnfortunately, there are currently no docs apart from this introduction. I hope\nthat codebase is not too difficult to follow, though, so if you can't wait, you\ncan peek into the source files.\n\nComparison to other libraries\n=============================\n\nTODO\n\nReporting bugs\n==============\n\nReport all bugs and feature requests to our `issue tracker`_.\n\n\n_issue tracker: https://github.com/Outernet-Project/sqlize/issues", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Outernet-project/sqlize", "keywords": "sql query builder", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "sqlize", "package_url": "https://pypi.org/project/sqlize/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/sqlize/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/Outernet-project/sqlize" }, "release_url": "https://pypi.org/project/sqlize/1.0/", "requires_dist": null, "requires_python": null, "summary": "Lightweight SQL query builder", "version": "1.0" }, "last_serial": 2329167, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "f266e4828b5fec7eca4fa5e5937e1317", "sha256": "54162606337cf905761cecf6fc8d6e31ed600830820af7408d1f5ec5decdc2cd" }, "downloads": -1, "filename": "sqlize-0.1.tar.gz", "has_sig": false, "md5_digest": "f266e4828b5fec7eca4fa5e5937e1317", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7353, "upload_time": "2015-04-02T11:51:32", "url": "https://files.pythonhosted.org/packages/c8/63/bbb0538722e46608161fa8a29064070bd00eb6d9ec4cb03f7491db712cd1/sqlize-0.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "d661c01d74bcd11d87fb503982d1b516", "sha256": "fa36164660dd9d9535abb6032d147496d98f47272e9e3da9d953debde1a443c5" }, "downloads": -1, "filename": "sqlize-0.1.zip", "has_sig": false, "md5_digest": "d661c01d74bcd11d87fb503982d1b516", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12468, "upload_time": "2015-04-02T11:51:35", "url": "https://files.pythonhosted.org/packages/4c/63/8675c3a5cd994cfaade975a9bcc1632be6e5c8a630f6451a30fb3371557a/sqlize-0.1.zip" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "d8e77044b0aa025a35d201161193ff1b", "sha256": "f826529f0a1b0fc0b7f64f92ecd4684418a1e945ab1829f38f9a16b0c04a3152" }, "downloads": -1, "filename": "sqlize-1.0.tar.gz", "has_sig": false, "md5_digest": "d8e77044b0aa025a35d201161193ff1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6724, "upload_time": "2016-09-07T10:40:17", "url": "https://files.pythonhosted.org/packages/0b/19/23a8ffd4855d9c90605aace677262238a81ce4d6a01014568224071ef89b/sqlize-1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "35dab20fbad0ca1c88ea23cb898a27ea", "sha256": "b8aa0a5839f758c4884d25d5b132837310d742fd744410cdbb324464c8cea9a3" }, "downloads": -1, "filename": "sqlize-1.0.zip", "has_sig": false, "md5_digest": "35dab20fbad0ca1c88ea23cb898a27ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12394, "upload_time": "2016-09-07T10:40:20", "url": "https://files.pythonhosted.org/packages/52/09/2f69efa35d8c0df2d6f9c3f2e54b880b46053e1a7127819b798b14a15139/sqlize-1.0.zip" } ], "1.0.dev1": [ { "comment_text": "", "digests": { "md5": "d8bcce53ec74fd7dc83e2e0bbd40f899", "sha256": "427268acf93a150383a4f2043015ac1b71cf70a887ca913d7bebcf4f36a85048" }, "downloads": -1, "filename": "sqlize-1.0.dev1.tar.gz", "has_sig": false, "md5_digest": "d8bcce53ec74fd7dc83e2e0bbd40f899", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6735, "upload_time": "2016-08-30T10:50:48", "url": "https://files.pythonhosted.org/packages/a9/fa/9774aa3ba96c4c4db09a5b1d17df77d3b06dad2256934702cfdacf8ccbcb/sqlize-1.0.dev1.tar.gz" }, { "comment_text": "", "digests": { "md5": "8281147a4f3b8b5212a37965a2de1eea", "sha256": "b50d84741f66a0c6e8fc9a2ae346753a49edc8c15682cd1fcf560f15cbcbd4b8" }, "downloads": -1, "filename": "sqlize-1.0.dev1.zip", "has_sig": false, "md5_digest": "8281147a4f3b8b5212a37965a2de1eea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12506, "upload_time": "2016-08-30T10:50:51", "url": "https://files.pythonhosted.org/packages/60/1c/44205107e3a16eb9813451101a7403c4f9f5e6c794cf20992a91e1879fcb/sqlize-1.0.dev1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d8e77044b0aa025a35d201161193ff1b", "sha256": "f826529f0a1b0fc0b7f64f92ecd4684418a1e945ab1829f38f9a16b0c04a3152" }, "downloads": -1, "filename": "sqlize-1.0.tar.gz", "has_sig": false, "md5_digest": "d8e77044b0aa025a35d201161193ff1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6724, "upload_time": "2016-09-07T10:40:17", "url": "https://files.pythonhosted.org/packages/0b/19/23a8ffd4855d9c90605aace677262238a81ce4d6a01014568224071ef89b/sqlize-1.0.tar.gz" }, { "comment_text": "", "digests": { "md5": "35dab20fbad0ca1c88ea23cb898a27ea", "sha256": "b8aa0a5839f758c4884d25d5b132837310d742fd744410cdbb324464c8cea9a3" }, "downloads": -1, "filename": "sqlize-1.0.zip", "has_sig": false, "md5_digest": "35dab20fbad0ca1c88ea23cb898a27ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12394, "upload_time": "2016-09-07T10:40:20", "url": "https://files.pythonhosted.org/packages/52/09/2f69efa35d8c0df2d6f9c3f2e54b880b46053e1a7127819b798b14a15139/sqlize-1.0.zip" } ] }