Home > Net >  Python Sql query variable not calling the values
Python Sql query variable not calling the values

Time:06-07

with open (r'D:\hang_sessions.csv') as csv_file:
csv_reader=csv.DictReader(csv_file,delimiter=',')
line_count=0
for row in csv_reader:
            sid = row['SID']
            serial = row['Serial']
            inst = row['Inst_ID']
            #User = row['User_Name']
            #print(sid, serial, inst, User)
print(sid, serial, inst)

c.execute('alter system kill session ":sid, :serial,@:inst" immediate ')

cx_Oracle.DatabaseError: ORA-00026: missing or invalid session ID Though serial/ session id is available yet i am getting this error, am i calling variables in wrong format!

CodePudding user response:

In Oracle, double quotes are for identifiers and single quotes are for string literals; you want a string literal.

c.execute(f"alter system kill session '{sid},{serial},@{inst}' immediate")
  • Related