dsn_tns = cx_Oracle.makedsn('myip', '1521', service_name='myservicename')
connection = cx_Oracle.connect(user='username', password='passwd', dsn=dsn_tns)
cursor = connection.cursor()
cursor.execute("INSERT INTO tablename VALUES (7.4)")
#above works ok
cursor.execute("INSERT INTO tablename VALUES (7:4)")
#above works with '7:4'
myvar='7:4'
cursor.execute('INSERT INTO tablename(col1) VALUES ({myvar})')
#cx_Oracle.DatabaseError: ORA-00936: missing expression
connection.commit()
connection.close()
My requirement to is to insert : to be insert in this tablename, column type of this tablename is varchar2. ( when i insert '0001' it also remove leading zeros and only insert '1' in tabename), above code connect oracle database table and create cursor to execute sql insert query. in insert query with values 7.4 if successfully update the table but in second insert it raise error with ORA-00917. i am using oracle version 11g and python 3.7.