Does anyone know why the connection string is not accepted? It gives me the following error
invalid syntax. Maybe ypu meat '==' or := instead of = ?
class BDMicrofzs(object):
dsn_tns = cx_Oracle.makedsn("x.x.x.x","xxxx",service_name = "xxxx")
conn_str = (user = "usuario", password = "contraseña", dsn = dsn_tns, encoding = "UTF-8")
def __init__(self, connection_string = conn_str):
self.connection_string = connection_string
self.connector = None
def __enter__(self):
self.connector = cx_Oracle.connect(self.connection_string)
return self
def __exit__(self,exc_type, exc_val, exc_tb):
if exc_tb is None:
self.connector.commit()
else:
self.connector.rollback()
self.connector.close()
def LimpiarTabla():
with oracle_connection() as conn:
limp = ("delete from temp_sol",conn)
This is bad:
You are assigning a tuple to a variable, but that tuple has undefined names:
user
,password
...The way recommended by the documentation is:
But if you insist on using a connection string, you can use this way :