Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python Sql query variable not calling the values

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!

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading