Metadata-Version: 2.4
Name: basedosdados
Version: 2.1.0b1
Summary: Organize and facilitate access to Brazilian data through public tables on BigQuery.
Project-URL: repository, https://github.com/basedosdados/sdk
Project-URL: documentation, https://basedosdados.org/docs/api_reference_python
Project-URL: issues, https://github.com/basedosdados/sdk/issues
Project-URL: source, https://github.com/basedosdados/sdk/tree/master/python-package
Author: Ricardo Dahis, Diego Oliveira
Author-email: Joao Carabetta <joao.carabetta@gmail.com>
Maintainer-email: Pedro Castro <pedro.castro@basedosdados.org>
License: MIT License
        
        Copyright (c) 2025 Base dos Dados
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: basedosdados,bigquery,datalake
Classifier: Topic :: Database
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: google-api-python-client>=2.86
Requires-Dist: google-cloud-bigquery-connection>=1.12
Requires-Dist: google-cloud-bigquery-storage>=2.19
Requires-Dist: google-cloud-bigquery>=3.10
Requires-Dist: google-cloud-storage>=2.9
Requires-Dist: gql>=3.4
Requires-Dist: loguru>=0.7.0
Requires-Dist: pandas-gbq>=0.19
Requires-Dist: pandas>=2.0
Requires-Dist: pandavro>=1.7
Requires-Dist: pydata-google-auth>=1.8
Requires-Dist: requests-toolbelt>=1
Requires-Dist: tomlkit>=0.11
Requires-Dist: tqdm>=4
Provides-Extra: all
Requires-Dist: gql; extra == 'all'
Requires-Dist: pandavro; extra == 'all'
Requires-Dist: requests-toolbelt; extra == 'all'
Provides-Extra: avro
Requires-Dist: pandavro; extra == 'avro'
Provides-Extra: upload
Requires-Dist: gql; extra == 'upload'
Requires-Dist: requests-toolbelt; extra == 'upload'
Description-Content-Type: text/markdown

# basedosdados

**basedosdados** is a Python package that provides easy access to Brazil’s largest open data lake, hosted on Google BigQuery. It allows you to query, download, and analyze high-quality, ready-to-use public datasets with minimal setup.

## Installation

Install from PyPI:

```bash
pip install basedosdados
```

Or using [uv](https://github.com/astral-sh/uv):

```bash
uv add basedosdados
```

Or with [poetry](https://python-poetry.org/):

```bash
poetry add basedosdados
```

## Quickstart

### Access a table

```python
import basedosdados as bd

df = bd.read_table('br_ibge_pib', 'municipio', billing_project_id="<YOUR-PROJECT>")
```

> On first use, you will be prompted to authenticate your Google Cloud project. [See how to create a project here.](https://basedosdados.org/docs/access_data_bq#bigquery)

### Run a SQL query

```python
import basedosdados as bd

query = """
SELECT *
FROM `basedosdados.br_tse_eleicoes.bens_candidato`
WHERE ano = 2020
AND sigla_uf = 'TO'
"""

df = bd.read_sql(query, billing_project_id="<YOUR-PROJECT>")
```

### Set global configuration

You can set your billing project globally to avoid passing it every time:

```python
import basedosdados as bd

bd.config.billing_project_id = "<YOUR-PROJECT-ID>"

query = """
SELECT *
FROM `basedosdados.br_bd_diretorios_brasil.municipio`
"""

df = bd.read_sql(query=query)
```

### Download query results to CSV

```python
import basedosdados as bd

query = """
SELECT ano, id_municipio, pib
FROM `basedosdados.br_ibge_pib.municipio`
WHERE ano = 2010
"""

bd.download("pib_2010.csv", query=query, billing_project_id="<YOUR-PROJECT>")
```

## Documentation

- [API Reference](https://basedosdados.org/docs/api_reference_python)

## Advanced: Multiple Configurations

If you need to use multiple service accounts or configurations, you can manage them by renaming the config folder and setting `bd.config.project_config_path`:

```python
import basedosdados as bd
bd.config.project_config_path = "/home/user/.bd_my_other_account"
```

## Contributing

See our [contribution guide](CONTRIBUTING.md) for how to help improve this package.

## License

MIT License. See [LICENSE](LICENSE) for details.

---

> Part of the [Base dos Dados](https://basedosdados.org) project – universalizing access to quality data in Brazil.
