Um módulo de conveniência para manipulação de bancos de dados IBM DB2 em Python.
Project description
coplin-db2
A biblioteca coplin-db2 é um módulo de conveniência para acessar bancos de dados do tipo IBM DB2, desenvolvido pela Coordenadoria de Planejamento Informacional da UFSM (COPLIN).
Com esta biblioteca, é possível definir um arquivo com credenciais de acesso ao banco de dados, no formato json, que
podem ser utilizadas posteriormente:
Arquivo credentials.json:
{
"user": "nome_de_usuário",
"password": "sua_senha_aqui",
"host": "URL_do_host",
"port": 50000,
"database": "nome_do_banco"
}
Arquivo db2_schema.sql:
CREATE TABLE USERS_TEST_IBMDB2(
ID INTEGER NOT NULL PRIMARY KEY,
NAME VARCHAR(10) NOT NULL,
AGE INTEGER NOT NULL
);
INSERT INTO USERS_TEST_IBMDB2(ID, NAME, AGE) VALUES (1, 'HENRY', 32);
INSERT INTO USERS_TEST_IBMDB2(ID, NAME, AGE) VALUES (2, 'JOHN', 20);
Arquivo main.py:
import os
from db2 import DB2Connection
# arquivo JSON com credenciais de login para o banco de dados
credentials = 'credentials.json'
with DB2Connection(credentials) as db2_conn:
db2_conn.create_tables('db2_schema.sql')
query_str = '''
SELECT *
FROM USERS_TEST_IBMDB2;
'''
df = db2_conn.query_to_dataframe(query_str)
print(df)
# deleta a tabela
# db2_conn.modify('''DROP TABLE USERS_TEST_IBMDB2;''', suppress=False)
A saída esperada deve ser:
ID NAME AGE
0 1 HENRY 32
1 2 JOHN 20
Instalação
Para instalar o pacote pelo pip, digite o seguinte comando:
pip install coplin-db2
Documentação
A documentação está disponível em https://coplin-ufsm.github.io/db2
Desenvolvimento
Para instruções de desenvolvimento do pacote, consulte este arquivo.
Contato
Biblioteca desenvolvida originalmente por Henry Cagnini: henry.cagnini@ufsm.br
Caso encontre algum problema no uso, abra um issue no repositório da biblioteca.
Pull requests são bem-vindos!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coplin_db2-2.2.tar.gz.
File metadata
- Download URL: coplin_db2-2.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b3f0268e29f0269825ba81ede3a17547a512cd2f2cd9dcf64a6fef4792a7f50
|
|
| MD5 |
e9aaa15a1d58b3ad8265257130b7e585
|
|
| BLAKE2b-256 |
ce10ecee0eda4968e342738d141e019887ee3c89516e0e37ebb34d2498744642
|
Provenance
The following attestation bundles were made for coplin_db2-2.2.tar.gz:
Publisher:
python-publish.yml on COPLIN-UFSM/db2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coplin_db2-2.2.tar.gz -
Subject digest:
1b3f0268e29f0269825ba81ede3a17547a512cd2f2cd9dcf64a6fef4792a7f50 - Sigstore transparency entry: 263363220
- Sigstore integration time:
-
Permalink:
COPLIN-UFSM/db2@b6147752e15ae4cf85a74ef5263af12862b237bd -
Branch / Tag:
refs/tags/2.2 - Owner: https://github.com/COPLIN-UFSM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b6147752e15ae4cf85a74ef5263af12862b237bd -
Trigger Event:
push
-
Statement type:
File details
Details for the file coplin_db2-2.2-py3-none-any.whl.
File metadata
- Download URL: coplin_db2-2.2-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7953c174944f37e80e63d87fc6f4709a357ea70d5ad1dfad4270f909c63997e3
|
|
| MD5 |
3a12fc7b9a80712871968bbe375f4b52
|
|
| BLAKE2b-256 |
7f8d7c39de695c1cf2e4ba6643f0aed32c11d8b565ca00150fe099821900c647
|
Provenance
The following attestation bundles were made for coplin_db2-2.2-py3-none-any.whl:
Publisher:
python-publish.yml on COPLIN-UFSM/db2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coplin_db2-2.2-py3-none-any.whl -
Subject digest:
7953c174944f37e80e63d87fc6f4709a357ea70d5ad1dfad4270f909c63997e3 - Sigstore transparency entry: 263363231
- Sigstore integration time:
-
Permalink:
COPLIN-UFSM/db2@b6147752e15ae4cf85a74ef5263af12862b237bd -
Branch / Tag:
refs/tags/2.2 - Owner: https://github.com/COPLIN-UFSM
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b6147752e15ae4cf85a74ef5263af12862b237bd -
Trigger Event:
push
-
Statement type: