python+oracle

python 下载install cx_Oracle
下载oracle客户端3个oci放入site-packages

https://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html


import cx_Oracle
db = cx_Oracle.connect('rdvs','rdvs','10.230.27.101/evsdev')#连接数据库
print(db)
cr=db.cursor()#创建cursor,游标对象
sql = "select * from scores s where s.degree in ('85','86','88')"
cr.execute(sql)#执行sql语句
rs = cr.fetchall()#一次取完所有数据
# fet=exe.fetchone()#一次取一行数据
print(rs)
cr.close()#关闭光标
db.close()#关闭数据库连接

猜你喜欢

转载自www.cnblogs.com/ssyyhh/p/9837739.html