{ "info": { "author": "Spencer Weston", "author_email": "Spencerweston3214@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License" ], "description": "# DatatoTable\nDatatotable converts data into SQLites tables automatically. The package is most useful when the name and number of columns in a table are large or unknown ahead of time as SQLalchemy's Object Relational mapper (ORM) requires manual generation of tables and their columns. Datatotable automates this process. Yet, it still allows manual additions of constraints, foreign keys, and other properties as desired. \n\n## Quick Start\nThe minimal use case of datatotable creates a table from a data source, and then inserts the data. This example walks through this process. Datatotable functions through two classes Database, which provides access to the database, and DataOperator, which interprets data for use with SQLalchemy. First, import these classes. Next, import a SQLalchemy Session class for inserts and tempfile to create a temporary directory.\n\n```python\nfrom datatotable.database import Database\nfrom datatotable.data import DataOperator\nfrom sqlalchemy.orm import Session\nimport tempfile\n```\nTo connect to or create a database, specify the name and directory of the database on Database's instantiation. Then, connect a session to the database via Database's engine property.\n```python\ntemp_dir = tempfile.TemporaryDirectory()\ndb = database.Database(name=\"sample\", directory=temp_dir.name)\nsession = Session(db.engine)\n```\n\nNext, pass data to DataOperator. The DataOperator's column property reads the data and returns a dictionary with column names as keys and lists of column attributes as values. \n```python\nraw_data = {\"col1\": [1,2,3,4], \"col2\": [\"hello\", \"world\", \"from\", \"computer\"], \"col3\": [10.1, 13.5, 23.2, 98.4]}\ndata = datatotable.data.DataOperator(raw_data)\ncolumns = data.columns\nprint(columns)\n>>> {'col1': [], 'col2': [], 'col3': []}\n```\n\nPass the columns to Database's map_table() function to create a mapped SQLalchemy Base class. After the table is mapped, call the create_tables() function to create the table in the database.\n```python\ndb.map_table(tbl_name=\"example_tbl\", column_types=columns)\ndb.create_tables()\n```\n\nWith the table created, access the table via the Database.table_mappings property. The table mapping can be used for queries or mapping data for inserts. The row property of DataOperator returns a list of dictionaries where each dictionary is a row in the database. Use ** notation to unpack each dictionary into a table object. A list comprehension, as used here, can create a list of table objects. Add these objects using Session.add_all().\n```python\nexample_tbl = db.table_mappings[\"example_tbl\"]\nexample_rows = [example_tbl(**row) for row in data.rows]\nsession.add_all(example_rows)\nsession.commit()\n```\n\nNow, check if the data is in the database.\n```python\nprint(session.query(example_tbl).count())\n>>> 4\n```\n\n## Version 0.3\nThis version is the first valid version uploaded to PyPi. It provides access to a database, automatically creates tables, and coerces data into a format that can be inserted into a table. It passes all tests in the test suite, but the test suite will need to be fleshed out as users come across problems not anticipated currently. \n\n## Future Development\n### Documentation\n1. Use Sphinx to create API documentation on Read the Docs\n2. A thorough tutorial to explain how constraints and relationships are established\n### Functionality\n1. Add functionality to relate SQLalchemy ORM objects when tables are created with foreign keys. This is a manual process currently.\n2. Allow simultaneous creation of multiple tables. Tables must be created one by one currently. \n\n## Author\nSpencer Weston\n\nspencerweston3214@gmail.com\n\n## License\nMIT\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Spencer-Weston/DatatoTable", "keywords": "data SQL sql SQLalchemy web-scraping data-management", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "datatotable", "package_url": "https://pypi.org/project/datatotable/", "platform": "", "project_url": "https://pypi.org/project/datatotable/", "project_urls": { "Homepage": "https://github.com/Spencer-Weston/DatatoTable" }, "release_url": "https://pypi.org/project/datatotable/0.3.1/", "requires_dist": [ "SQLAlchemy (>=1.2.17)" ], "requires_python": "", "summary": "Create SQLite database tables automatically from data", "version": "0.3.1", "yanked": false, "yanked_reason": null }, "last_serial": 6024290, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "4146fbdef71874294b25fae3d99c7023", "sha256": "57376bd0d73a0809468132682802396d77655f192a0782ee5519b83daa262df4" }, "downloads": -1, "filename": "DataToTable-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4146fbdef71874294b25fae3d99c7023", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9120, "upload_time": "2019-10-23T19:38:41", "upload_time_iso_8601": "2019-10-23T19:38:41.766797Z", "url": "https://files.pythonhosted.org/packages/d0/e2/1a3d1f58641fb5f21b65732632526f39327d0e782ba1507ae78201eee4b5/DataToTable-0.2-py3-none-any.whl", "yanked": false, "yanked_reason": null } ], "0.2.dev1": [ { "comment_text": "", "digests": { "md5": "f4c3227964c2e7dbea391ae3969edc44", "sha256": "50a4b685116c115d006e7b1d16fa7080769a256872e39c1be35df8e8ec9b2cb8" }, "downloads": -1, "filename": "datatotable-0.2.dev1-py3-none-any.whl", "has_sig": false, "md5_digest": "f4c3227964c2e7dbea391ae3969edc44", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9263, "upload_time": "2019-10-23T19:38:43", "upload_time_iso_8601": "2019-10-23T19:38:43.987787Z", "url": "https://files.pythonhosted.org/packages/85/77/5fda8b39d7d2de099b883b1594800e7a4a884b46ead589ebb50e4ef833da/datatotable-0.2.dev1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "912e9bba0e168bc352880a1b213fb832", "sha256": "d935bd4371f288ae2a3781a66c0a09d966e282220583a939de44b227922616ce" }, "downloads": -1, "filename": "datatotable-0.2.dev1.tar.gz", "has_sig": false, "md5_digest": "912e9bba0e168bc352880a1b213fb832", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7175, "upload_time": "2019-10-23T19:38:47", "upload_time_iso_8601": "2019-10-23T19:38:47.063558Z", "url": "https://files.pythonhosted.org/packages/4f/0d/a75887544d0dea0247ef9efdc85d21c4d581b53a80a65b057f3f40ad969a/datatotable-0.2.dev1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.3": [ { "comment_text": "", "digests": { "md5": "76bbaaed01bd6d308249f332de56c706", "sha256": "4996eb0c784ba5ff996e47f8576ee8ebdadd28fdb6ae0727c4d0b5b20de8fde8" }, "downloads": -1, "filename": "datatotable-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "76bbaaed01bd6d308249f332de56c706", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10335, "upload_time": "2019-10-23T19:38:45", "upload_time_iso_8601": "2019-10-23T19:38:45.526781Z", "url": "https://files.pythonhosted.org/packages/8f/79/987465a2038a78b1c54ea3afe4929cb636f579963abfdc97cc1c573606dd/datatotable-0.3-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "0f5bf15a4fbaa040c6062fa2dc6c4953", "sha256": "f30455ba238106001a92d0272767986e0c0811f82b5b7c4c744cbec83b2cbcc8" }, "downloads": -1, "filename": "datatotable-0.3.tar.gz", "has_sig": false, "md5_digest": "0f5bf15a4fbaa040c6062fa2dc6c4953", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8301, "upload_time": "2019-10-23T19:38:48", "upload_time_iso_8601": "2019-10-23T19:38:48.495664Z", "url": "https://files.pythonhosted.org/packages/68/5f/120371fd352211da311e9837533d8eb19d22f9a5d76b5068d575363bdba4/datatotable-0.3.tar.gz", "yanked": false, "yanked_reason": null } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "7f35ab87bcf87a13079cef54c88a9bc6", "sha256": "f5f817c8965159e02b4912e12de02650900321a3938cf873872b386b41e2cb45" }, "downloads": -1, "filename": "datatotable-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7f35ab87bcf87a13079cef54c88a9bc6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10023, "upload_time": "2019-10-24T14:48:48", "upload_time_iso_8601": "2019-10-24T14:48:48.625560Z", "url": "https://files.pythonhosted.org/packages/b6/ba/317ebb9ec463c1297c5edf7aa04e4a9e96e081cf30eada190fecfef7486e/datatotable-0.3.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "cdfd2b311ac4722afb611ec5cec25336", "sha256": "51ff2a6ce526873edcb145e9b93f5cd6f00b5005e19858b0e64b8cde53f35446" }, "downloads": -1, "filename": "datatotable-0.3.1.tar.gz", "has_sig": false, "md5_digest": "cdfd2b311ac4722afb611ec5cec25336", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8214, "upload_time": "2019-10-24T14:48:50", "upload_time_iso_8601": "2019-10-24T14:48:50.467718Z", "url": "https://files.pythonhosted.org/packages/0c/4d/17491722390bb1f2916d091f698075562e129d43e258e2c6058c0d5e804d/datatotable-0.3.1.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7f35ab87bcf87a13079cef54c88a9bc6", "sha256": "f5f817c8965159e02b4912e12de02650900321a3938cf873872b386b41e2cb45" }, "downloads": -1, "filename": "datatotable-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7f35ab87bcf87a13079cef54c88a9bc6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10023, "upload_time": "2019-10-24T14:48:48", "upload_time_iso_8601": "2019-10-24T14:48:48.625560Z", "url": "https://files.pythonhosted.org/packages/b6/ba/317ebb9ec463c1297c5edf7aa04e4a9e96e081cf30eada190fecfef7486e/datatotable-0.3.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "cdfd2b311ac4722afb611ec5cec25336", "sha256": "51ff2a6ce526873edcb145e9b93f5cd6f00b5005e19858b0e64b8cde53f35446" }, "downloads": -1, "filename": "datatotable-0.3.1.tar.gz", "has_sig": false, "md5_digest": "cdfd2b311ac4722afb611ec5cec25336", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8214, "upload_time": "2019-10-24T14:48:50", "upload_time_iso_8601": "2019-10-24T14:48:50.467718Z", "url": "https://files.pythonhosted.org/packages/0c/4d/17491722390bb1f2916d091f698075562e129d43e258e2c6058c0d5e804d/datatotable-0.3.1.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }