{ "info": { "author": "Matthaeus Deutsch", "author_email": "mdeutsch@outlook.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# dbrequests\n\n[![Build Status](https://travis-ci.org/INWTlab/dbrequests.svg?branch=master)](https://travis-ci.org/INWTlab/dbrequests)\n\n**dbrequests is a python package built for easy use of raw SQL within python and pandas projects.**\n\nIt uses ideas from [records](https://github.com/kennethreitz/records/) and is built using [sqlalchemy-engines](https://www.sqlalchemy.org/), but is more heavily integrated with pandas. It aims to reproduce the pilosophy behind the R-package [dbtools](https://github.com/INWT/dbtools/).\n\n\n_Database support includes RedShift, Postgres, MySQL, SQLite, Oracle, and MS-SQL (drivers not included)._\n\n## Usage\n\n### Send queries and bulk queries\n\nEasy sending of raw sql and output as pandas DataFrames, with creds or the url of the database:\n\n```python\nfrom dbrequests import Database\n\ndb = Database(creds=creds)\ndf = db.send_query(\"\"\"\n SELECT * FROM test;\n \"\"\")\ndf # table test as pandas DataFrame\n```\n\nYou can put the sql query in a file and direct `send_query` to the file. The sql-file may be parametrized:\n\n```sql\nSELECT {col1}, {col2} FROM test;\n\n```\n\n```python\nfrom dbrequests import Database\n\ndb = Database(creds=creds, sql_dir = '/path/to/dir/')\ndb.send_query('select', col1='id', col2='name')\ndf # table test, including columns 'id', 'name' as pandas DataFrame\n```\n\nYou can also pass arguments to pandas `read_sql`-Function:\n\n```python\nfrom dbrequests import Database\n\ndb = Database(creds=creds, sql_dir = '/path/to/dir/')\ndb.send_query('select', col1='id', col2='name', index_col='id')\ndf # table test, including column 'name' as pandas DataFrame with index 'id'\n```\n\nYou may also send queries with no table as output to the database via `send_bulk_query`, which exhibits the same behavior as `send_query`:\n\n```python\ndb.send_bulk_query('drop test from test;')\n```\n\n### Send data\n\nEasy sending of pandas Dataframes in multiple modes:\n\n```python\ndb.send_data(df, 'table', mode='insert')\n```\n\nSupported modes are:\n - 'insert': Appending new records. Duplicate primary keys will result in errors (sql insert into).\n - 'truncate': Delete the table and completely rewrite it (sql truncate and insert into).\n - 'replace': Replace records with duplicate primary keys (sql replace into).\n - 'update': Update records with duplicate primary keys (sql insert into duplicate key update).\n\n### Uitilities\n\n- Database.get_table_names will give existing tables in the database\n- Parameters such es `chunksize` for `pandas.to_sql` may be given to the wrapper function `send_data` and are handed over to pandas. The same is true for `send_query`.\n- For transactions the context manager `transaction` may be of use.\n\n## Installation\n\nThe package can be installed via pip:\n\n```\npip install dbrequests\n```\n\n\n## Version 1.0\n - implemented send_data and send_query wrappers for pandas sql-functionality\n\n## Version 1.0.8\n - renamed to dbrequests\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/INWTlab/dbrequests", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "dbrequests", "package_url": "https://pypi.org/project/dbrequests/", "platform": "", "project_url": "https://pypi.org/project/dbrequests/", "project_urls": { "Homepage": "https://github.com/INWTlab/dbrequests" }, "release_url": "https://pypi.org/project/dbrequests/1.0.9/", "requires_dist": [ "pandas", "SQLAlchemy ; python_version >= \"3.0\"", "pymysql ; extra == 'mysql'", "psycopg2 ; extra == 'pg'", "sqlalchemy-redshift ; extra == 'redshift'", "psycopg2 ; extra == 'redshift'" ], "requires_python": "", "summary": "Python package for querying and connecting to databases.", "version": "1.0.9" }, "last_serial": 5510866, "releases": { "1.0.8": [ { "comment_text": "", "digests": { "md5": "e6c86836e9fcefd18b0d40e6ee6f99c3", "sha256": "cd280550e190e21022b9d6ceff5630dec0cac761a7cdf2b0b4514464c4066eeb" }, "downloads": -1, "filename": "dbrequests-1.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "e6c86836e9fcefd18b0d40e6ee6f99c3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11063, "upload_time": "2019-07-10T08:42:24", "url": "https://files.pythonhosted.org/packages/b0/c2/b94d3b160649db3bb341250893416f1664339c1bb729d0601598c134eae8/dbrequests-1.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4178116511cb3c86be240c6316d683f1", "sha256": "8de46de2873258229ef892714f13c26bba8ff884d0f9d2ee4abf9881e6e6c659" }, "downloads": -1, "filename": "dbrequests-1.0.8.tar.gz", "has_sig": false, "md5_digest": "4178116511cb3c86be240c6316d683f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10331, "upload_time": "2019-07-10T08:42:27", "url": "https://files.pythonhosted.org/packages/d5/5a/b2939bedd0a386ae9e914d8be842de12f3f809036a5b9ba643eed14898ee/dbrequests-1.0.8.tar.gz" } ], "1.0.9": [ { "comment_text": "", "digests": { "md5": "b323bac555747e379683e3a6ede93c99", "sha256": "a2a668f0650d2c69ee11a83e8023c2d4f84e398ca61c6c4084cf8d5fc3f5ccfb" }, "downloads": -1, "filename": "dbrequests-1.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "b323bac555747e379683e3a6ede93c99", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11029, "upload_time": "2019-07-10T08:54:55", "url": "https://files.pythonhosted.org/packages/be/df/974a0fde4ddd2ead9c3b9a10dcb4343ec96ff323f5d3be43b1e71d520481/dbrequests-1.0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d82920dd20c3bd0b56ee6e1ea38661d5", "sha256": "1deb027accb587b7f6f020aa3b2cfcdec2fea358ad43c05ccfd5f04f7a84e5f9" }, "downloads": -1, "filename": "dbrequests-1.0.9.tar.gz", "has_sig": false, "md5_digest": "d82920dd20c3bd0b56ee6e1ea38661d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10258, "upload_time": "2019-07-10T08:54:58", "url": "https://files.pythonhosted.org/packages/5f/44/5397635c290bcaa55e82557944d87365f4d025aa34d73907e5d22425d740/dbrequests-1.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b323bac555747e379683e3a6ede93c99", "sha256": "a2a668f0650d2c69ee11a83e8023c2d4f84e398ca61c6c4084cf8d5fc3f5ccfb" }, "downloads": -1, "filename": "dbrequests-1.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "b323bac555747e379683e3a6ede93c99", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11029, "upload_time": "2019-07-10T08:54:55", "url": "https://files.pythonhosted.org/packages/be/df/974a0fde4ddd2ead9c3b9a10dcb4343ec96ff323f5d3be43b1e71d520481/dbrequests-1.0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d82920dd20c3bd0b56ee6e1ea38661d5", "sha256": "1deb027accb587b7f6f020aa3b2cfcdec2fea358ad43c05ccfd5f04f7a84e5f9" }, "downloads": -1, "filename": "dbrequests-1.0.9.tar.gz", "has_sig": false, "md5_digest": "d82920dd20c3bd0b56ee6e1ea38661d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10258, "upload_time": "2019-07-10T08:54:58", "url": "https://files.pythonhosted.org/packages/5f/44/5397635c290bcaa55e82557944d87365f4d025aa34d73907e5d22425d740/dbrequests-1.0.9.tar.gz" } ] }