我正在尝试连接到oracle数据库并使用以下代码在python中使用cx_Oracle执行查询
import cx_Oracle
mobileNumber='1234567890'
dbHost='some_value'
dbPortNumber='some_value'
dbUsername='some_value'
dbPasswd='some_value'
dsn_tns = cx_Oracle.makedsn(dbHost, dbPortNumber, service_name='ORCL')
conn = cx_Oracle.connect(user=dbUsername, password=dbPasswd, dsn=dsn_tns)
cur=conn.cursor()
query='insert into table_name values ((select max(ID)+1 from table_name),"sms","'+ mobileNumber + '")'
cur.execute(query)
res=cur.fetchall()
print (res)
但是运行此代码时出现以下异常
Traceback (most recent call last):
File "script.py", line 16, in <module>
result=cur.fetchall()
cx_Oracle.InterfaceError: not a query
打印变量 query 的值时,我正在关注
insert into table_name values ((select max(ID)+1 from table_name),"sms","1234567890")