Skip to main content

Standard Oracle Using (queries, updates, inserts)

Project description

pyDbOracle

Está lib foi desenvolvida para facilitar o dia a dia de quem precisa martelar comandos a moda antiga (SELECT, UPDATE, INSERT) em bancos oracle.

Instalação

pip install pyDbOracle

Utilização

Alguns exemplos de uso.

Conexão básica

from pyDbOracle.database import Database
str_conn = 'oracle://<USER>:<PASS>@<HOST>:<PORT>/<INSTANCE>'
db = Database(str_conn)
db.info()

Conexão em banco com RAC

from pyDbOracle.database import Database
str_conn = 'oracle://<USER>:<PASS>@<HOST>:<PORT>/<INSTANCE>?threaded=True'
db = Database(str_conn)
db.info()

Executando queries

from pyDbOracle.database import Database
str_conn = 'oracle://<USER>:<PASS>@<HOST>:<PORT>/<INSTANCE>'
db = Database(str_conn)
command = 'SELECT INSTANCE_NAME FROM V$INSTANCE'
data = db.get(command=command)
print(data)
# {'instance_name': 'PROD'}

Executando queries com filtros

from pyDbOracle.database import Database
str_conn = 'oracle://<USER>:<PASS>@<HOST>:<PORT>/<INSTANCE>'
db = Database(str_conn)
command = 'SELECT INSTANCE_NAME FROM V$INSTANCE WHERE HOST = :host'
params = dict(host='MEUHOST')
data = db.get(command=command, params=params)
print(data)
# {'instance_name': 'PROD'}

Executandos Inserts, Updates ou Deletes

Quando precisar executar um comando do tipo insert, update ou delete, rodar o metodo run

from pyDbOracle.database import Database
str_conn = 'oracle://<USER>:<PASS>@<HOST>:<PORT>/<INSTANCE>'
db = Database(str_conn)
command = 'INSERT INTO TABELA (COLUNA1, COLUNA2) VALUES (:valor1, :valor2)'
params = dict(valor1='ABC', valor2=123)
data = db.run(command=command, params=params)
print(data)
# 1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyDbOracle-0.2.tar.gz (4.7 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page