Pycharm中Python3连接Oracle
生活随笔
收集整理的這篇文章主要介紹了
Pycharm中Python3连接Oracle
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
一、環(huán)境配置:
系統(tǒng):win7、10 (64位)
軟件:1.Python3.7.2 (64位)
2.instantclient-basic-windows.x64-11.2.0.4.0.zip(64位) --這個必須要安裝
?百度網(wǎng)盤下載地址:https://pan.baidu.com/s/1wuOUIT7wmnIm5iq-50fFvQ 提取碼:6f8g
3.Oracle 11gR2 (64位)
最好要保持Python、instantclient和Oracle位數(shù)一致(我本機安裝的都是64位的)!!!
二、步驟:
2.1 把instantclient-basic-windows.x64-11.2.0.4.0.zip解壓到某一目錄并把目錄配置到系統(tǒng)環(huán)境變量Path中
2.2 下載安裝vcredist_x64.exe,安裝好后重啟電腦,必須要重啟一下
2.3 安裝cx_Oracle: pip install cx_Oracle
三、測試:
import cx_Oracle class My_plsq:def my_cha(self,my_sql_c):try:conn = cx_Oracle.connect("連接名","密碼","localhost/orcl")cursor = conn.cursor()cursor.execute(my_sql_c)all_data = cursor.fetchall()oo = list(all_data[0])return ooexcept cx_Oracle.DatabaseError:return print("無效的SQL語句") if __name__ == '__main__':a=My_plsq()l=a.my_cha("SELECT * FROM 表名")print(l)
親測有效
?
轉(zhuǎn)載于:https://www.cnblogs.com/Mr-Simple001/p/10516148.html
總結(jié)
以上是生活随笔為你收集整理的Pycharm中Python3连接Oracle的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2.13 break和continue
- 下一篇: 面试又栽在JVM调优上了!