{ "info": { "author": "Daniel Kn\u00fcttel", "author_email": "daniel.knuettel@daknuett.eu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Affero General Public License v3", "Programming Language :: Python :: 3" ], "description": "webdb\n*****\n\nwebdb provides a simple JSON based database interface for\nclient side data access in web applications.\n\n.. contents::\n\n\nWhat is webdb?\n==============\n\nwebdb is an adapter between you client side application\n(most probably written in JS in a browser) and your\ndatabases on the server. It can be used to access file, \nSQL, NoSQL and any other database you want using simple \nHTTP GET and POSTs.\n\nHow does it work?\n=================\n\nwebdb is a cherrypy application that should be mounted under\na protected path. Typical would be ``/database``. All the\nauthentication stuff must be handled by cherrypy. \nThe application accesses the database using and instance of\n``webdb.adapters.AbstractDBMS``. This instance will dispatch\nthe right database (one might use several databases) and\nhandle the request.\n\nRequests\n========\n\nRequests are HTTP GET requests for pulling and HTTP POST for\npushing data. The query is always encoded in JSON objects:\n\n.. _webdbrequest:\n\n::\n\n\twebdbrequest\n\t\t.database : string\n\t\t.request\n\t\t\t.table : string\n\t\t\t.operation : string\n\t\t\t.parameters: object\n\n``webdbrequest.database``\n\tString name of the database. This name will be used\n\tto dispatch the right database adapter.\n``webdbrequest.request.table``\n\tString name of the table to access.\n``webdbrequest.request.operation``\n\tString name of the operation. It is one of\n\t``INSERT``, ``UPDATE``, ``DELETE``, ``SELECT``\n\n``webdbrequest.request.parameters``\n\tIs a JSON object containing the parameters of the\n\tquery. The structure depends on the operation:\n\n\t``INSERT``\n\t\tThe parameter is just a map of key value pairs that\n\t\twill be attempted to put::\n\n\t\t\t.parameters: {string: value}\n\n\t``UPDATE``\n\t\tThe parameter is an object containing\n\t\ta *set* and a *where* block::\n\n\t\t\t.parameters\n\t\t\t\t.where: {string: value}\n\t\t\t\t.set: {string: value}\n\t\t\n\t\tAll key value pairs in *where* will be\n\t\tinterpreted as ``AND`` joined conditions,\n\t\tall key value pairs in *set* will be\n\t\tinterpreted as substitutions for the current\n\t\tvalues.\n\t\n\t``DELETE``\n\t\tThe parameter is a map ``{string: value}``\n\t\tthat will be interpreted as ``AND`` joined\n\t\tconditions::\n\n\t\t\t.parameters: {string: value}\n\t\n\t``SELECT``\n\t\tThe parameter is an object containing\n\t\ta *where* and a *what* block::\n\n\t\t\t.parameters\n\t\t\t\t.where: {string: value}\n\t\t\t\t.what: list\n\n\t\t*where* will be interpreted as in ``UPDATE``,\n\t\t*what* is the list of columns to fetch.\n\t\t\n\n``value`` is one of the following types: \nstring, integer, float, boolean, date, time, datetime.\n\nSee `Handling Date and Time`_.\n\n\n.. _webdbresult:\n\t\nThe server will return data depending on what the adapter\nreturns. If the adapter returns an exception, the server\nwill set the HTTP status to 404, the content-type to\n``text/plain`` and return a (maybe) useful text.\nIf the server returns a structured result (for instance the\nresult of a SQL SELECT) it will set the HTTP status to 200\nand the content-type to ``application/json`` and return the\njson encoded data.\nIf the server returns nothing but the query did succeed it\nwill set the HTTP status to 204 and return nothing.\n\nIsolating Users\n===============\n\nThere might be several users accessing the same\ndatabase/table/whatever. To isolate access to this shared\ndata the ``inject`` operation can be used. The\n``AbstractDBMS`` has an attribute ``inject`` that should be\na nested function returning the attribute value to inject\nand an attribute ``inject_as`` that should be set to the\nname of the table column that should be inserted.\n\nA typical application might set the username in the session\nand inject the username in the query::\n\n\tdbms = AbstractDBMS(\n\t\t\tinject = lambda: cherrypy.session[\"username\"], \n\t\t\tinject_as = \"username\")\n\n**Note**: This will not actually work. One cannot\ninstantiate ``AbstractDBMS``, as it is abstract. This sample\nis just meant to be a hint how one can implement injections.\n\nHandling Date and Time\n======================\n\nDate and time are handled as JSON objects with a magic\nattribute (the ``__type__``) ::\n\n\ttime\n\t\t.__type__ = \"time\"\n\t\t.hour: int\n\t\t.minute: int\n\t\t.second: int\n\t\t.microsecond: int\n\t\t.utcoffset: int\n\n\tdate\n\t\t.__type__ = \"date\"\n\t\t.year: int\n\t\t.month: int\n\t\t.day: int\n\n\tdatetime\n\t\t.__type__ = \"datetime\"\n\t\t.year: int\n\t\t.month: int\n\t\t.day: int\n\t\t.hour: int\n\t\t.minute: int\n\t\t.second: int\n\t\t.microsecond: int\n\t\t.utcoffset: int\n\n\nSee also: \n\n- `utcoffset `_\n- `python date and time representation `_\n\nOne can omit some attributes, they will be filled with zeros\nautomatically.\n\nFiles\n=====\n\n``webdb`` is also capable of serving files. This can be done\nby creating a ``webdb.interface.file.FileInterface``\ninstance and providing it with\na ``webdb.files.dispatcher.AbstractFileDispatcher``.\n\nThere are already three implementations:\n\n``UserFileDispatcher``\n\tAllows full access to a private directory for all\n\tusers.\n\n``QuotaUserFileDispatcher``\n\tAllows full access to a private directory for all\n\tusers. Rejects to write once the quota is exceeded.\n\n``SQLFileDispatcher``\n\tAllows access to files according to a database.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/daknuett/webdb", "keywords": "database web json", "license": "AGPL v3", "maintainer": "", "maintainer_email": "", "name": "webdb", "package_url": "https://pypi.org/project/webdb/", "platform": "", "project_url": "https://pypi.org/project/webdb/", "project_urls": { "Homepage": "https://github.com/daknuett/webdb" }, "release_url": "https://pypi.org/project/webdb/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Adapter for exposing databases to the web", "version": "0.0.2" }, "last_serial": 3604990, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "892541f8e944856fb466cc4e5737fdc1", "sha256": "e81ac9a2b1db31ed0b57c8773000263022d7b6c914d691ab0f5d6da3f662a318" }, "downloads": -1, "filename": "webdb-0.0.1-py3.6.egg", "has_sig": false, "md5_digest": "892541f8e944856fb466cc4e5737fdc1", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 37139, "upload_time": "2018-02-22T10:36:57", "url": "https://files.pythonhosted.org/packages/0b/51/1bb68662f3950311e5266c7a59d9af87c8ac41d01a87f6eb7f4fb00f9d9b/webdb-0.0.1-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "2f425d76a56c66732bad4d92fafb178e", "sha256": "9ff75d4a9563acd19c4bffd7e283d2a475ad0c9e6f823e173f25d768ee9d63e3" }, "downloads": -1, "filename": "webdb-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "2f425d76a56c66732bad4d92fafb178e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 18715, "upload_time": "2018-02-22T10:36:50", "url": "https://files.pythonhosted.org/packages/59/61/4ddbb3b12d9c63fec23dce6549c8830a947bc52bdbabb31b85d40e87dbfb/webdb-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cbeb275ca6e35aff9ab4050d7f0cb481", "sha256": "65c97f9bf936f50603493d2f36a679b0297c21e7b3bddb8f24289e724b76b8ef" }, "downloads": -1, "filename": "webdb-0.0.1.tar.gz", "has_sig": false, "md5_digest": "cbeb275ca6e35aff9ab4050d7f0cb481", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13758, "upload_time": "2018-02-22T10:36:59", "url": "https://files.pythonhosted.org/packages/96/dd/c1d95c48b249c905ecca1cd9d2a3de783603276b0636d4d079a1eb909a47/webdb-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "47d4e9d24e116af0120182d530571295", "sha256": "0abeaf82d1b3f29589a5b276c80f8b77f3c1912e71a91f1c9f3a842d34443639" }, "downloads": -1, "filename": "webdb-0.0.2-py3.6.egg", "has_sig": false, "md5_digest": "47d4e9d24e116af0120182d530571295", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 37369, "upload_time": "2018-02-22T10:44:58", "url": "https://files.pythonhosted.org/packages/48/e1/a53afee4eded3952830f554d658c2d3b4e9a61126e0135181dedeadc16e0/webdb-0.0.2-py3.6.egg" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47d4e9d24e116af0120182d530571295", "sha256": "0abeaf82d1b3f29589a5b276c80f8b77f3c1912e71a91f1c9f3a842d34443639" }, "downloads": -1, "filename": "webdb-0.0.2-py3.6.egg", "has_sig": false, "md5_digest": "47d4e9d24e116af0120182d530571295", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 37369, "upload_time": "2018-02-22T10:44:58", "url": "https://files.pythonhosted.org/packages/48/e1/a53afee4eded3952830f554d658c2d3b4e9a61126e0135181dedeadc16e0/webdb-0.0.2-py3.6.egg" } ] }