# datasus-db
[![PyPI version](https://badge.fury.io/py/datasus-db.svg)](https://pypi.org/project/datasus-db/ "Go to project PyPi page")
[![Documentation](https://img.shields.io/badge/Documentation-3fba11)](https://mymatsubara.github.io/datasus-db/datasus_db.html "Go to project documentation")
A python package to **download and import** public available data from **DATASUS's** ftp servers into a [DuckDB](https://duckdb.org/) database.
## Why DuckDB?
[DuckDB](https://duckdb.org/) is a local database similar to [sqlite](https://www.sqlite.org/index.html), but it is tailor made with analytical processing in mind, which makes it a great tool for analysing DATASUS's data. To see all the features DuckDB provides, check out their [documentation](https://www.sqlite.org/index.html).
## Installation
```
pip install datasus-db
```
## Usage
```python
import datasus_db
import logging
def main():
# If you want to enable logging
logging.getLogger().setLevel(logging.INFO)
# Import SIM DO (Sistema de Informações de Mortalidade - Declarações de Óbito) data
# By default the data is imported to the file `datasus.db`
datasus_db.import_sim_do()
# Import SIH RD (Sistema de Informações Hospitalares do SUS - AIH Reduzida) data
# If you want, you can import to another duckdb file changing the `db_file` argument
datasus_db.import_sih_rd(db_file="other-name.db")
# Import PO (Painel de Oncologia) data
datasus_db.import_po()
# Import IBGE POP (População IBGE - Agregada por município, sexo e faixa etaria) data
datasus_db.import_ibge_pop()
# Import IBGE POP TCU (População IBGE - Tribunal de Contas da União) data
datasus_db.import_ibge_pop_tcu()
# Import auxiliar tables (Municipios, UFs e doenças)
datasus_db.import_auxiliar_tables()
if __name__ == "__main__":
main()
```
## Documentation
Check out the project's documentation:
[![View documentation](https://img.shields.io/badge/VIEW-DOCUMENTATION-3fba11?style=for-the-badge)](https://mymatsubara.github.io/datasus-db/datasus_db.html "Go to project documentation")
## Found a bug or want a new feature?
Feel free to create an [issue](https://github.com/mymatsubara/datasus-dbc-py/issues/new) here if you found a bug or if you want a new feature!
Raw data
{
"_id": null,
"home_page": "https://github.com/mymatsubara/datasus-db",
"name": "datasus-db",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11,<4.0",
"maintainer_email": "",
"keywords": "datasus,duckdb,data science,database",
"author": "Murilo Matsubara",
"author_email": "murilo.matsubara@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/18/51/ba9f1b3521f72a4089e5433a751aacca50341403261e430cd85bfe41e756/datasus_db-0.1.1.tar.gz",
"platform": null,
"description": "# datasus-db\n\n[![PyPI version](https://badge.fury.io/py/datasus-db.svg)](https://pypi.org/project/datasus-db/ \"Go to project PyPi page\")\n[![Documentation](https://img.shields.io/badge/Documentation-3fba11)](https://mymatsubara.github.io/datasus-db/datasus_db.html \"Go to project documentation\")\n\nA python package to **download and import** public available data from **DATASUS's** ftp servers into a [DuckDB](https://duckdb.org/) database.\n\n## Why DuckDB?\n[DuckDB](https://duckdb.org/) is a local database similar to [sqlite](https://www.sqlite.org/index.html), but it is tailor made with analytical processing in mind, which makes it a great tool for analysing DATASUS's data. To see all the features DuckDB provides, check out their [documentation](https://www.sqlite.org/index.html).\n\n\n## Installation\n```\npip install datasus-db\n```\n\n## Usage\n\n```python\nimport datasus_db\nimport logging\n\n\ndef main():\n # If you want to enable logging\n logging.getLogger().setLevel(logging.INFO)\n\n # Import SIM DO (Sistema de Informa\u00e7\u00f5es de Mortalidade - Declara\u00e7\u00f5es de \u00d3bito) data\n # By default the data is imported to the file `datasus.db`\n datasus_db.import_sim_do()\n\n # Import SIH RD (Sistema de Informa\u00e7\u00f5es Hospitalares do SUS - AIH Reduzida) data\n # If you want, you can import to another duckdb file changing the `db_file` argument\n datasus_db.import_sih_rd(db_file=\"other-name.db\")\n\n # Import PO (Painel de Oncologia) data\n datasus_db.import_po()\n\n # Import IBGE POP (Popula\u00e7\u00e3o IBGE - Agregada por munic\u00edpio, sexo e faixa etaria) data\n datasus_db.import_ibge_pop()\n\n # Import IBGE POP TCU (Popula\u00e7\u00e3o IBGE - Tribunal de Contas da Uni\u00e3o) data\n datasus_db.import_ibge_pop_tcu()\n\n # Import auxiliar tables (Municipios, UFs e doen\u00e7as)\n datasus_db.import_auxiliar_tables()\n\n\nif __name__ == \"__main__\":\n main()\n```\n\n## Documentation\nCheck out the project's documentation:\n\n[![View documentation](https://img.shields.io/badge/VIEW-DOCUMENTATION-3fba11?style=for-the-badge)](https://mymatsubara.github.io/datasus-db/datasus_db.html \"Go to project documentation\")\n\n## Found a bug or want a new feature?\nFeel free to create an [issue](https://github.com/mymatsubara/datasus-dbc-py/issues/new) here if you found a bug or if you want a new feature!\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Download and import DATASUS's public data to a DuckDB database",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/mymatsubara/datasus-db",
"Repository": "https://github.com/mymatsubara/datasus-db"
},
"split_keywords": [
"datasus",
"duckdb",
"data science",
"database"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "51b56dec319c3fc087a648ba62fc7deb73af8afd51bba904669961f2bbc88a52",
"md5": "d4f2ba7917a29f72f9d9df2058423748",
"sha256": "f5e1de3613f0f8c1757d1def313b9b815bcb25bd1cddfe0f80ddc2b647dea93e"
},
"downloads": -1,
"filename": "datasus_db-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d4f2ba7917a29f72f9d9df2058423748",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11,<4.0",
"size": 19500,
"upload_time": "2023-12-07T20:45:48",
"upload_time_iso_8601": "2023-12-07T20:45:48.736494Z",
"url": "https://files.pythonhosted.org/packages/51/b5/6dec319c3fc087a648ba62fc7deb73af8afd51bba904669961f2bbc88a52/datasus_db-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1851ba9f1b3521f72a4089e5433a751aacca50341403261e430cd85bfe41e756",
"md5": "c6b471eb53c7767eef774b9660c878aa",
"sha256": "cd63dfac41ffaa8245a81f22996e308902aa28d815501e6a045e7e809789eb25"
},
"downloads": -1,
"filename": "datasus_db-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "c6b471eb53c7767eef774b9660c878aa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11,<4.0",
"size": 12799,
"upload_time": "2023-12-07T20:45:51",
"upload_time_iso_8601": "2023-12-07T20:45:51.401264Z",
"url": "https://files.pythonhosted.org/packages/18/51/ba9f1b3521f72a4089e5433a751aacca50341403261e430cd85bfe41e756/datasus_db-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-07 20:45:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mymatsubara",
"github_project": "datasus-db",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "datasus-db"
}