A Python tool for downloading, processing, and storing data from the Brazilian Securities and Exchange Commission (CVM - Comissão de Valores Mobiliários) in a SQLite database.
Project description
CVM-SQLite
CVM-SQLite is a Python tool for downloading, processing, and storing data from the Brazilian Securities and Exchange Commission (CVM - Comissão de Valores Mobiliários) in a SQLite database.
Features
- Automatically downloads data from the CVM repository
- Processes and structures data according to provided schemas
- Stores data in a SQLite database
- Supports incremental updates
Installation
You can install the CVM Data Processor directly from GitHub using pip:
pip install cvm-sqlite
Usage
from cvm_sqlite import CVMDataProcessor
# Initialize the processor
processor = CVMDataProcessor(
db_path='path/to/your/database.db',
cvm_url='https://dados.cvm.gov.br/dados/CIA_ABERTA',
verbose=True
)
# Run the processor
processor.run()
# Now you can use the processor object to run queries
results = processor.query("""
SELECT
CAST(STRFTIME('%Y', DT_REFER) AS INTEGER) AS exercise,
DENOM_CIA AS company,
VL_CONTA AS net_income
FROM dfp_cia_aberta_DRE
WHERE CNPJ_CIA = '00.000.000/0001-91'
AND GRUPO_DFP = 'DF Consolidado - Demonstração do Resultado'
AND ORDEM_EXERC = 'ÚLTIMO'
AND (
(CD_CONTA = '3.09' AND STRFTIME('%Y', DT_REFER) < '2020')
OR (CD_CONTA = '3.11' AND STRFTIME('%Y', DT_REFER) >= '2020')
)
ORDER BY exercise
""")
Parameters
db_path: Path to the SQLite database file.cvm_url: URL of the CVM directory (optional, default: https://dados.cvm.gov.br/dados/CIA_ABERTA).verbose: Enables detailed output (optional, default:False).
Note: It is mandatory that the CVM directory includes a META folder at any level, which contains the table schemas.
How it works
If the database doesn't exist, it will be created. From the URL provided, all files and directories that can be accessed from this URL will be mapped. The tables are created according to the schema file provided by the CVM itself. If the database already exists, only necessary updates will be made, processing only new files or those whose last modification date has changed.
License
This project is licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cvm_sqlite-1.0.0.tar.gz.
File metadata
- Download URL: cvm_sqlite-1.0.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6499c213ce101d21a2632e7902f81a1be2d72d0e00b49f3b2bc84c733fa44743
|
|
| MD5 |
6c04a374481eb458277c83e41be563bf
|
|
| BLAKE2b-256 |
2b2bdef5f00dc506e9df26f6dabd200a13272dce35ac1e55d15125b80c709b70
|