{ "info": { "author": "18F", "author_email": "catherine.devlin@gsa.gov", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", "Natural Language :: English", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: SQL", "Topic :: Database", "Topic :: Software Development :: Code Generators" ], "description": "# sql_insert_writer\n\n[![PyPI Status](https://img.shields.io/pypi/v/sql_insert_writer.svg)](https://pypi.python.org/pypi/sql_insert_writer)\n[![CircleCI](https://circleci.com/gh/18F/sql_insert_writer.svg?style=svg)](https://circleci.com/gh/18F/sql_insert_writer)\n[![Code Climate](https://codeclimate.com/github/18F/sql_insert_writer/badges/gpa.svg)](https://codeclimate.com/github/18F/sql_insert_writer)\n[![Test Coverage](https://codeclimate.com/github/18F/sql_insert_writer/badges/coverage.svg)](https://codeclimate.com/github/18F/sql_insert_writer/coverage)\n[![Dependency Status](https://gemnasium.com/badges/github.com/18F/sql_insert_writer.svg)](https://gemnasium.com/github.com/18F/sql_insert_writer)\n\nHelps generate highly readable SQL INSERT statements\n\nCalling with one table name creates an `INSERT INTO... VALUES` statement:\n\n```\n$ sql_insert_writer pet\n\nINSERT INTO pet (\n id,\n name,\n species_name,\n planet,\n kg\n)\nVALUES\n(\n DEFAULT, -- ==> id\n DEFAULT, -- ==> name\n DEFAULT, -- ==> species_name\n DEFAULT, -- ==> planet\n DEFAULT -- ==> kg\n)\n```\n\nIf more table names are added, will generate an `INSERT INTO... SELECT FROM`\nstatement, matching as many column names as it can between the destination\nand source table(s):\n\n```\n\n$ sql_insert_writer pet animal\n\nINSERT INTO pet (\n id,\n name,\n species_name,\n planet,\n kg\n)\nSELECT\n id, -- ==> id\n name, -- ==> name\n species_name, -- ==> species_name\n planet, -- ==> planet\n DEFAULT -- ==> kg\nFROM animal\n```\n\n## More usage examples\n\nhttps://github.com/18F/sql_insert_writer\n\n## Rationale\n\nThe syntax of `INSERT` statements makes it difficult to tell which destination columns a value is intended for,\nespecially in inserts with many columns. (Our five-column example is not bad, but imagine fifty columns!)\n\nComments can clarify the link between data source and destination, but adding those comments manually is tedious and error-prone.\n\nExplicitly listing the destination columns of an `INSERT` is another best practice often skipped due to tedium.\n\nThe output of `sql_insert_writer` will rarely be fully ready to execute, but it should save the bulk of the typing.\n\n## Features\n\n- Supports PostgreSQL, SQLite, MySQL\n- Accepts [SQLAlchemy database URLs](http://docs.sqlalchemy.org/en/latest/core/engines.html) with `--db` option. Defaults to environment variable `$DATABASE_URL`.\n- Any number of source tables; columns chosen in order specified\n- Any number of tuples in `VALUES` clause with `--tuples` option\n- Explicitly cast to destination column type with `--cast` option\n\n## Installation\n\n[Installation instructions](docs/installation.rst)\n\nDevelopment installation instructions, so that\nyou can modify the code and contribute your\nimprovements back to the project, are included\nin the [CONTRIBUTING documentation](CONTRIBUTING.rst).\n\n## Planned features\n\n- Support for more databases\n- Approximate column name matches\n- Omit inserts into auto-incrementing primary key columns\n- Pre-fill JOIN clauses with foreign keys where possible\n\n## Limitations\n\nWe do not deal well with case-sensitive table or column names; for lo, they are an abomination unto Codd.\n\n## Credits\n\nThis package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter)\nand the [18F/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage)\nproject template.\n\n## Public domain\n\nThis project is in the worldwide [public domain](LICENSE.md). As stated in [CONTRIBUTING](CONTRIBUTING.rst):\n\n> This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).\n>\n> All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.\n\n\n=======\nHistory\n=======\n\n0.1.0 (2017-10-12)\n------------------\n\n* First release on PyPI.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/18F/sql_insert_writer", "keywords": "sql_insert_writer", "license": "CC0 license", "maintainer": "", "maintainer_email": "", "name": "sql-insert-writer", "package_url": "https://pypi.org/project/sql-insert-writer/", "platform": "", "project_url": "https://pypi.org/project/sql-insert-writer/", "project_urls": { "Homepage": "https://github.com/18F/sql_insert_writer" }, "release_url": "https://pypi.org/project/sql-insert-writer/0.1.0/", "requires_dist": [ "Click (>=6.7)", "records (==0.5.2)", "attrdict (==2.0.0)" ], "requires_python": "", "summary": "Helps make long SQL INSERT statements readable", "version": "0.1.0" }, "last_serial": 3842120, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a9c2a68e5bc17979b3ccb01c89ddc841", "sha256": "2199c0193c62363e426c987d65d171feba8a68237d3da32b1841144f3c32cc0b" }, "downloads": -1, "filename": "sql_insert_writer-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a9c2a68e5bc17979b3ccb01c89ddc841", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9364, "upload_time": "2017-10-12T20:35:40", "url": "https://files.pythonhosted.org/packages/e7/1e/4546725ccf246ddfc13b3a598537d3985df10562213e2deb24db8bc48d75/sql_insert_writer-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "28142f82ba2b9b876fc83325a59ab9b8", "sha256": "30077563e9e351fcaff786aa5b28aff05449e194e1ff5b8d0365c65cb0949641" }, "downloads": -1, "filename": "sql_insert_writer-0.1.0.tar.gz", "has_sig": false, "md5_digest": "28142f82ba2b9b876fc83325a59ab9b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11649, "upload_time": "2017-10-12T20:35:41", "url": "https://files.pythonhosted.org/packages/46/de/76245247f47adc4af1c275a1e5f02bcfb59b62e7b802e4a1558a61e43f70/sql_insert_writer-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a9c2a68e5bc17979b3ccb01c89ddc841", "sha256": "2199c0193c62363e426c987d65d171feba8a68237d3da32b1841144f3c32cc0b" }, "downloads": -1, "filename": "sql_insert_writer-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a9c2a68e5bc17979b3ccb01c89ddc841", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9364, "upload_time": "2017-10-12T20:35:40", "url": "https://files.pythonhosted.org/packages/e7/1e/4546725ccf246ddfc13b3a598537d3985df10562213e2deb24db8bc48d75/sql_insert_writer-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "28142f82ba2b9b876fc83325a59ab9b8", "sha256": "30077563e9e351fcaff786aa5b28aff05449e194e1ff5b8d0365c65cb0949641" }, "downloads": -1, "filename": "sql_insert_writer-0.1.0.tar.gz", "has_sig": false, "md5_digest": "28142f82ba2b9b876fc83325a59ab9b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11649, "upload_time": "2017-10-12T20:35:41", "url": "https://files.pythonhosted.org/packages/46/de/76245247f47adc4af1c275a1e5f02bcfb59b62e7b802e4a1558a61e43f70/sql_insert_writer-0.1.0.tar.gz" } ] }