I don't know if someone can help me, I'm trying to query a database, I have the connection from a separate module which I could already call in the script I'm doing. but when executing it gives me this error 'function' object has no attribute 'cursor', I don't understand why it is failing,
This is the function that I have in module, where I make the connection to the base:
def BDSu():
dsn_tns = cx_Oracle.dsn(
"x.x.x.x",
"xxxx",
service_name="service_name"
)
try:
connection = cx_Oracle.connect(user="usuario", password="contraseña",dsn=dsn_tns,encoding="UTF-8")
print(connection.version)
return connection
except Exception as err:
print("Error tratando de conectar con la base de datos")
print(err)
and this is the function that I have in another module, in which I import the previous function, and I try to execute a .sql file from this module, I have already tried executing the query from BDSu() and it runs fine there, but when I do it in the other module Queries() it doesn't run, I think I'm making a mistake but I can't locate it.
def Consultas():
from con_Bases import BDSu as Su
try:
with open("./UnicaS4.sql",'r') as query:
data = query.read()
cursor = S4u.cursor()
cursor.execute(data)
datos = cursor.fetchall()
cursor.close
for row in datos:
print(row)
except Exception as err:
print("Error tratando de ejecutar consulta")
print(err)
your function call is missing