{ "info": { "author": "Simone Murzilli; Guido Barbaglia", "author_email": "geobrickspy@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Geobricks DBMS\n==============\n\nThis project provides DBMS functionalities to Geobricks modules, enabling CRUD methods for different types of DB (e.g. [PostgreSQL](http://www.postgresql.org/), [MongoDB](http://www.mongodb.org/), etc). The main script is ```dbms_core.py``` which acts as a generic gateway to the class that implements specific methods for each data source.\n\nInstallation\n============\n\nThe plug-in is distributed through PyPi and can be installed by typing the following command in the console:\n```\npip install geobricksdbms\n```\n\nExamples\n========\nThe main class is ```DBMS``` contained in ```dbms_core.py```. The initialization method of such class accepts the following arguments:\n\n|Name|Description|Default|Example|\n|----|-----|-------|-------|\n|```datasource```|Name of a default datasource.|```None```|```my_datasource```||\n|```vendor```|DB connector to use|```None```||\n|```db_name```|Name of the DB|```None```|my_db|\n|```username```|Username to access the DB|```None```|my_username|\n|```password```|Password to access the DB|```None```|my_password|\n|```collection_name```|Name of the collection (MongoDB only)|```None```|my_collection|\n\nOnce initialized the ```DBMS``` class provides a set of CRUD methods as discussed in the following sections.\n\nMongoDB\n-------\nThe example below shows how to connect to the _test_ data source and to the _posts_ collection:\n```python\nmy_db = DBMS('mongodb', 'test', collection_name='posts')\n```\nOnce the connection has been estabilished it is possible to query the DB. The ```find_all``` method retrieves all the items of the collection:\n```python\nfor row in my_db.find_all():\n print row\n```\nIt is also possible to select a single item by ID:\n```python\nitem = my_db.find_by_id('547305f8f8cd671df13e6765')\n```\nThe ```insert``` method allows the user to add new documents in the collection:\n```python\nnew_id = my_db.insert({'my_field': 'my_value'})\nprint new_id\n```\n\nPostgreSQL\n----------\nThe example below shows how to connect to the _geobricks_ data source:\n```python\nmy_db = DBMS('postgresql', 'geobricks', 'my_username', 'my_password')\n```\nOnce the connection has been estabilished it is possible to query the DB. The ```find_all``` method retrieves all the items of the collection, and takes the table name as argument:\n```python\nfor row in my_db.find_all('tasks'):\n print row\n```\nTo insert a new item in the DB you will have to specify the table name and provide a ```Dict``` where the keys represents the column names and the values are the values to be stored in the DB. As istance the following code:\n```python\nmy_db.insert({'year': '2014', 'month': '11'}, 'tasks')\n```\nadd the following record in the _tasks_ table:\n\n|year|month|day|hour|second|\n|----|-----|---|----|------|\n|2014|11||||\n\nOnly the fields specified in the ```Dict``` have been stored in the _tasks_ table.\n\nConnect by datasource name\n--------------------------\nIt is possible to connect to a default datasource with no need to send the parameters to the init function. This is particularly useful when the DB must be accessed through the REST services and it is not safe, ot at least not recomendable, to embed usernames and/or password in the URL's. Available datasources are stored in a default DB that is configured in the ```config/dbms_config.py``` file. The default datasource can be PostgreSQL, MongoDB or any vendor supported by Geobricks DBMS. The following example shows the configuration for a PostgreSQL default DB:\n```python\nconfig = {\n \"default_datasource\": {\n \"vendor\": \"postgresql\",\n \"db_name\": \"my_db\",\n \"table_name\": \"datasources\",\n \"username\": \"my_username\",\n \"password\": \"my_password\"\n }\n}\n```\nThese are the required field to configure a PostgreSQL default datasource:\n\n|Field Name|Field Description|Example|\n|----------|-----------------|-------|\n|```vendor```|Database vendor|```postgresql```|\n|```db_name```|Name of the DB for the connection|```my_db```|\n|```table_name```|Name of the table containing the default datasources|```datasources```|\n|```username```|Username for the connection|```my_username```|\n|```password```|Password for the connection|```my_password```|\n\nFollowing an example for the configuration of a MongoDB default datasource:\n```python\nconfig = {\n \"default_datasource\": {\n \"vendor\": \"mongodb\",\n \"db_name\": \"my_db\",\n \"collection\": \"datasources\"\n }\n}\n```\nThe following are the required parameters:\n\n|Field Name|Field Description|Example|\n|----------|-----------------|-------|\n|```vendor```|Database vendor|```postgresql```|\n|```db_name```|Name of the DB for the connection|```my_db```|\n|```collection```|Name of the table collection containing the default datasources|```datasources```|\n\nThe default datasource provides the details for a DB containing all the available datasources. Such datasources are identified by the ```datasource``` field. Each datasource must provide the following information:\n\n|Field Name|Field Description|Example|Notes|\n|----------|-----------------|-------|-----|\n|```id```|Record ID|```123456```|SQL only|\n|```datasource```|Unique identifier|```test_db```||\n|```vendor```|DB vendor|```postgresql```||\n|```db_name```|Name of the DB for the connection|```my_db```||\n|```username```|Username for the connection|```my_username```|SQL only|\n|```password```|Password for the connection|```my_password```|SQL only|\n|```collection```|Name of the table collection containing thes default datasources|```posts```|NoSQL only|\n\nPlease note that the default DB is different from the datasources. It is possible to use a SQL DB as repository for the datasources and have only NoSQL DB's. The ```datasource``` field is used to fetch all the required parameters to connect to the specified datasource. The following example show how to list all the items contained in the ```tasks``` table by providing the datasource name:\n```python\nmy_db = DBMS(datasource='test_postgresql')\nfor row in my_db.find_all('tasks'):\n print row\n```\nThe ```test_postgresql``` datasource is stored in the default DB and, in the case of a SQL DB, it is described as follow:\n\n|id |datasource |vendor |db_name|username|password |collection|\n|------|---------------|----------|-------|--------|----------|----------|\n|123456|test_postgresql|postgresql|test |postgres|mypassword|```null```|\n\nThe document for the same datasource in a NoSQL default DB is the following:\n\n```json\n{\n \"datasource\": \"test_postgresql\",\n \"vendor\": \"postgresql\",\n \"db_name\": \"test\",\n \"username\": \"postgres\",\n \"password\": \"mypassword\"\n}\n```", "description_content_type": null, "docs_url": "https://pythonhosted.org/GeobricksDBMS/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/GeobricksDBMS/", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "GeobricksDBMS", "package_url": "https://pypi.org/project/GeobricksDBMS/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/GeobricksDBMS/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/GeobricksDBMS/" }, "release_url": "https://pypi.org/project/GeobricksDBMS/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "Geobricks DB Management System.", "version": "0.1.5" }, "last_serial": 1462800, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "2e32730fce09a68b9a2c427cf7525d82", "sha256": "de23e1609a136a4bf23af6b6749a804cda0cb9218c8a6abbd81331b32ceeb15a" }, "downloads": -1, "filename": "GeobricksDBMS-0.1.0.tar.gz", "has_sig": false, "md5_digest": "2e32730fce09a68b9a2c427cf7525d82", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10790, "upload_time": "2014-11-24T14:42:43", "url": "https://files.pythonhosted.org/packages/c6/63/1693f1cfcd187b299ebae2de5a255415284717f0dcd077afa84c9eea66ba/GeobricksDBMS-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1008140f78a45324a48848d7da6de9ce", "sha256": "39bd41f934b3f903fa73df54d919bd1c5f989d8ce958cfebe7bb4bfa903e191b" }, "downloads": -1, "filename": "GeobricksDBMS-0.1.1.tar.gz", "has_sig": false, "md5_digest": "1008140f78a45324a48848d7da6de9ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13320, "upload_time": "2014-11-25T15:11:28", "url": "https://files.pythonhosted.org/packages/af/ab/5c10481062c168f5f42542d5d24efefc81c57a0fc278dcbbe14ba0d424a2/GeobricksDBMS-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "bd2f39c052fb2f403837cb97b23a36d8", "sha256": "9919aa12892034842fe1468c4afdf23f7a3b817eb07af484e312349dcdea87cb" }, "downloads": -1, "filename": "GeobricksDBMS-0.1.2.tar.gz", "has_sig": false, "md5_digest": "bd2f39c052fb2f403837cb97b23a36d8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19748, "upload_time": "2014-12-01T16:09:21", "url": "https://files.pythonhosted.org/packages/f4/5d/57ca58f0efd2b40adc6d456771b2e76fbffb1a841437be4384752958c5de/GeobricksDBMS-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "3f1c0ca9b5ce2496da896581d565c875", "sha256": "6a9a6a2fa46d91afd1e8b75cae2bd4eb3eab8e23648add7305f66ecd9615a7d6" }, "downloads": -1, "filename": "GeobricksDBMS-0.1.3.tar.gz", "has_sig": false, "md5_digest": "3f1c0ca9b5ce2496da896581d565c875", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19761, "upload_time": "2014-12-10T14:54:51", "url": "https://files.pythonhosted.org/packages/28/2b/1992e0996ec81320298bc4b711b37d2a8ef8f91428530bd94d53f8766667/GeobricksDBMS-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "e0021d3223ce072664db5c42126d76ac", "sha256": "45786a14ce13c0292623b6a07200a703ca2682b9367da78d966927ca7354c30e" }, "downloads": -1, "filename": "GeobricksDBMS-0.1.4.tar.gz", "has_sig": false, "md5_digest": "e0021d3223ce072664db5c42126d76ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20353, "upload_time": "2015-01-13T10:52:55", "url": "https://files.pythonhosted.org/packages/48/6a/c9c44ea29612ed7576adc28f21ceabc268a3dd28c674d59b746d31f1dac3/GeobricksDBMS-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "02d20bb14a98f27590aff273c8f6e9f9", "sha256": "4bbb423da6061bff5991a842994a87373ddbfbb3c182d9ca0da212674986a0a2" }, "downloads": -1, "filename": "GeobricksDBMS-0.1.5.tar.gz", "has_sig": false, "md5_digest": "02d20bb14a98f27590aff273c8f6e9f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20057, "upload_time": "2015-03-16T14:21:52", "url": "https://files.pythonhosted.org/packages/20/5f/544d1eaf915668bdff95fbc74ce5692751efd5bffda77dfd9021b517c1b1/GeobricksDBMS-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "02d20bb14a98f27590aff273c8f6e9f9", "sha256": "4bbb423da6061bff5991a842994a87373ddbfbb3c182d9ca0da212674986a0a2" }, "downloads": -1, "filename": "GeobricksDBMS-0.1.5.tar.gz", "has_sig": false, "md5_digest": "02d20bb14a98f27590aff273c8f6e9f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20057, "upload_time": "2015-03-16T14:21:52", "url": "https://files.pythonhosted.org/packages/20/5f/544d1eaf915668bdff95fbc74ce5692751efd5bffda77dfd9021b517c1b1/GeobricksDBMS-0.1.5.tar.gz" } ] }