Metadata-Version: 2.1
Name: datasus-db
Version: 0.1.1
Summary: Download and import DATASUS's public data to a DuckDB database
Home-page: https://github.com/mymatsubara/datasus-db
License: MIT
Keywords: datasus,duckdb,data science,database
Author: Murilo Matsubara
Author-email: murilo.matsubara@gmail.com
Requires-Python: >=3.11,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: datasus-dbc (>=0.1.1,<0.2.0)
Requires-Dist: dbfread (>=2.0.7,<3.0.0)
Requires-Dist: duckdb (>=0.9.2,<0.10.0)
Requires-Dist: polars (>=0.19.19,<0.20.0)
Requires-Dist: pyarrow (>=14.0.1,<15.0.0)
Project-URL: Repository, https://github.com/mymatsubara/datasus-db
Description-Content-Type: text/markdown

# 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!



