cursor.execute("select name from v$datafile;")
执行 sql 语句提示无效字符。
原因就是我加入了 ;
号。
改成 cursor.execute("select name from v$datafile")
就好了。
问题源码如下:
import cx_Oracle as cxcon = cx.connect('ncc2020_0609', 'sys', '10.10.xx.xx:1521/orcl') # 创建连接
cursor = con.cursor() # 创建游标
cursor.execute("select name from v$datafile;") # 执行sql语句
for i in cursor: # 打印数据print(i)
cursor.close() # 关闭游标
con.close() # 关闭数据库连接
报错信息:
修改后运行效果图:
喜欢的点个赞?吧!