欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CX_ORACLE连接方法

程序员文章站 2024-03-24 20:55:28
...
import cx_Oracle

conn = cx_Oracle.connect('yb_ya/***@10.254.254.*:1521/yaybdb',encoding="UTF-8")
cursor = conn.cursor()
cursor.execute('select * from ac01 where rownum <= 5')
result = cursor.fetchall()
print (cursor.rowcount)
for row in result:
    print(row)  #此处特别注意前面空格
cursor.close()
conn.close()