{ "info": { "author": "Aidan Feldman", "author_email": "aidan.l.feldman@census.gov", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# sas2db [![PyPI version](https://badge.fury.io/py/sas2db.svg)](https://badge.fury.io/py/sas2db)\n\nImports [SAS]() files to SQL databases. Supports both `*.sas7bdat` and XPORT (`*.xpt`) files.\n\n## Installation\n\n_The SAS software itself is not required._\n\n1. Install [Python 3](https://www.python.org/downloads/) and [pip](https://pip.pypa.io/en/stable/installing/).\n1. Install the package.\n\n ```sh\n pip3 install sas2db\n ```\n\n## Usage\n\n### SQLite3\n\n`sas2db` supports [SQLite3](https://www.sqlite.org/) with no additional dependencies or setup, so we'll start with that. To import from SAS to SQLite3:\n\n1. Run the conversion.\n\n ```sh\n sas2db path/to/src.sas7bdat\n ```\n\n1. A `src.db` (matching your input file name) will be created.\n1. Run SQL! Example:\n\n ```\n $ sqlite3 src.db\n sqlite> .tables\n mydata\n sqlite> SELECT COUNT(*) FROM mydata;\n 200\n ```\n\nFor more options:\n\n```sh\nsas2db -h\n```\n\n### Other databases\n\nAside from SQLite3, `sas2db` supports other databases like PostgreSQL and MySQL. This support comes from [SQLAlchemy](https://www.sqlalchemy.org/) under the hood, so see [their list of supported \"dialects\"](https://docs.sqlalchemy.org/en/latest/dialects/index.html).\n\nTo use another database:\n\n1. Ensure that the destination database is installed, running, created, and accessible from wherever you will be doing the import.\n1. Install the corresponding driver.\n - On the [Dialects](https://docs.sqlalchemy.org/en/latest/dialects/index.html) page, click your preferred database, then under \"DBAPI Support\", click one of the options.\n - The first DBAPI option is probably fine, though you may have to try multiple.\n1. Run `sas2db`, passing the [database URL](https://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls) to the `--db` argument.\n\nExample for PostgreSQL:\n\n```sh\n# create the database\ncreatedb -U postgres sas_import\n# install driver\npip3 install psycopg2\n# run the import\nsas2db --db postgresql+psycopg2://postgres@localhost:5432/sas_import path/to/src.sas7bdat\n```\n\n## Development\n\n1. Install [Pipenv](https://pipenv.readthedocs.io/en/latest/).\n1. Clone/download the repository.\n1. From the project directory, run\n\n ```sh\n pipenv install --dev\n pipenv shell\n ```\n\n1. Run PostgreSQL. Example in Docker:\n\n ```sh\n docker run --rm -it -p 5432:5432 --name pg postgres\n ```\n\n1. Create `sas2db` database in PostgreSQL for testing. Example in Docker:\n\n ```sh\n docker exec -it pg createdb -U postgres sas2db\n ```\n\n1. Run tests:\n\n ```sh\n python -m unittest\n ```\n\nTo use the script:\n\n```sh\npython3 sas2db/run.py path/to/src.sas7bdat\n```\n\n[data.gov has data sets you can test with.](https://catalog.data.gov/dataset?res_format=Zipped+SAS7BDAT)\n\n## More Information\n\nOther tools to look at for importing/exporting data to/from SAS:\n\n- [sas7bdat Python package](https://pypi.org/project/sas7bdat/)\n - Useful in case you can't use Pandas for some reason\n - Pandas (used in `sas2db`) uses [a modified version of the sas7bdat package](https://github.com/pandas-dev/pandas/blob/master/pandas/io/sas/sas7bdat.py)\n- [SAS ODBC drivers](http://support.sas.com/software/products/odbc/index.html)\n- SAS's [`PROC EXPORT`](http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000393175.htm)\n- [sas2bdat R package](https://cran.r-project.org/web/packages/sas7bdat/index.html)\n\nInformation about data types:\n\n- Documentation\n - [SQLite types](https://www.sqlite.org/datatype3.html#affinity_name_examples)\n - [SAS data types](http://support.sas.com/documentation/cdl/en/fedsqlref/67364/HTML/default/viewer.htm#n19bf2z7e9p646n0z224cokuj567.htm)\n - [SAS formats](http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm)\n- SAS to Python type parsing\n - [sas7bdat](https://bitbucket.org/jaredhobbs/sas7bdat/src/d712283fd4a7319c7dffe44b17f25d7917e63724/sas7bdat.py#lines-454:490)\n - [Pandas](https://github.com/pandas-dev/pandas/blob/0409521665bd436a10aea7e06336066bf07ff057/pandas/io/sas/sas7bdat.py#L659-L685)\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/XDgov/sas2db", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "sas2db", "package_url": "https://pypi.org/project/sas2db/", "platform": "", "project_url": "https://pypi.org/project/sas2db/", "project_urls": { "Homepage": "https://github.com/XDgov/sas2db" }, "release_url": "https://pypi.org/project/sas2db/0.2.1/", "requires_dist": [ "inflection (<1,>0.3)", "pandas (<1,>0.24)", "sqlalchemy (<2,>1.3)" ], "requires_python": ">=3", "summary": "Import SAS files to SQL databases", "version": "0.2.1" }, "last_serial": 5365544, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "55fecc2413607ac5093431d939c774a1", "sha256": "a8c92a7089116a75c01009c66e447d9d0e95d6a3dc9bf2444158a52672f9b88c" }, "downloads": -1, "filename": "sas2db-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "55fecc2413607ac5093431d939c774a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 8808, "upload_time": "2018-12-04T20:59:39", "url": "https://files.pythonhosted.org/packages/a4/89/222ecda65126a5f4723bfdaaa20d59c6aafce57f107e33a5f652a7c19969/sas2db-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c967580fe5e8222bfee7bb62750c3357", "sha256": "b928994f3ec3d0c7b0e316f7033ababbd6b64af170bbc243d094500d80bb278a" }, "downloads": -1, "filename": "sas2db-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c967580fe5e8222bfee7bb62750c3357", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5061, "upload_time": "2018-12-04T20:59:41", "url": "https://files.pythonhosted.org/packages/1a/c1/967acfcf3e942d9af36a04713b7d4b8de3fa24dcf3eb6df30e8d1abc802c/sas2db-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "c0fa75b6e1e9627c0b1cff7cb927df68", "sha256": "818294f908201e3a5b51e173fd98b48598dee7d9baf0dfaaf1c2051978554883" }, "downloads": -1, "filename": "sas2db-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c0fa75b6e1e9627c0b1cff7cb927df68", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 9075, "upload_time": "2019-06-06T05:22:42", "url": "https://files.pythonhosted.org/packages/cf/ba/c0c8b675a8fca1f330823783a32870b6488748a2b537e8c0f5d8ceb5b178/sas2db-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "023e07a74a31afd82805a2539dc38669", "sha256": "4163e81cab643dc6bea68f38a54ffaf15c93b0c987127f7dcba20f309e7038f0" }, "downloads": -1, "filename": "sas2db-0.2.1.tar.gz", "has_sig": false, "md5_digest": "023e07a74a31afd82805a2539dc38669", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5408, "upload_time": "2019-06-06T05:22:43", "url": "https://files.pythonhosted.org/packages/c3/3a/c7cdd5c1c5d4a65320693264bb4cb7ea46a6e7bc500fee81a869502fe077/sas2db-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c0fa75b6e1e9627c0b1cff7cb927df68", "sha256": "818294f908201e3a5b51e173fd98b48598dee7d9baf0dfaaf1c2051978554883" }, "downloads": -1, "filename": "sas2db-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c0fa75b6e1e9627c0b1cff7cb927df68", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 9075, "upload_time": "2019-06-06T05:22:42", "url": "https://files.pythonhosted.org/packages/cf/ba/c0c8b675a8fca1f330823783a32870b6488748a2b537e8c0f5d8ceb5b178/sas2db-0.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "023e07a74a31afd82805a2539dc38669", "sha256": "4163e81cab643dc6bea68f38a54ffaf15c93b0c987127f7dcba20f309e7038f0" }, "downloads": -1, "filename": "sas2db-0.2.1.tar.gz", "has_sig": false, "md5_digest": "023e07a74a31afd82805a2539dc38669", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5408, "upload_time": "2019-06-06T05:22:43", "url": "https://files.pythonhosted.org/packages/c3/3a/c7cdd5c1c5d4a65320693264bb4cb7ea46a6e7bc500fee81a869502fe077/sas2db-0.2.1.tar.gz" } ] }