Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import oracledb

lib_dir = r"C:\Users\llqto\Desktop\prueba\instantclient_18_5"
oracledb.init_oracle_client(lib_dir=lib_dir)

class dtrConnexion:
@staticmethod
def getConnection():
user = 'aaaa'
password = 'aaaa'
host = 'aaaa'
port = 'aaaa'
service_name = 'aaaa'

connection = None
try:
dsn = oracledb.makedsn(host, port, service_name)
# Establecer la conexión con el modo Basic
connection = oracledb.connect(user=user, password=password, dsn=dsn)
print("-- CONEXION EXITOSA --")
except oracledb.Error as e:
print("-- ERROR EN LA CONEXION --", e)

return connection

@staticmethod
def getCloses():
close = dtrConnexion()
try:
close.getConnection().close()
print("-- CONEXION CERRADA --")

except oracledb.Error as e:
print("-- CONEXION NO CERRADA --", e)

dtrConnexion().getConnection()

You might also like