robotframework遠端連線oracle配置方法
robotframework中需要連線到oracle進行資料庫操作,配置方式:
1、RF伺服器上安裝oracle客戶端Instant Client
Note:此處的安裝和navicat的安裝不同在於軟體版本,navicat與oracle:https://blog.csdn.net/ChenLeihappy/article/details/79873429,此處Instant Client要與python的版本保持一致,本例中均為64位。
下載地址:http://www.oracle.com/technetwork/cn/topics/winx64soft-101515-zhs.html
instantclient-basic-windows.x64-11.2.0.4.0.zip instantclient-sqlplus-windows.x64-11.2.0.4.0.zip instantclient-sdk-windows.x64-11.2.0.4.0.zip |
解壓到一個資料夾:instantclient_11_2,配置環境變數:
NS_ADMIN=D:\oracle\instantclient_11_2 NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK path變數後面新增D:\oracle\instantclient_11_2;D:\oracle\instantclient_11_2\sdk; |
2、RF伺服器上安裝cx_Oracle模組
下載連結:https://oracle.github.io/python-cx_Oracle/
也可pip安裝,同時需要安裝databaselibrary python庫:
pip install cx_Oracle
pip install robotframework-databaselibrary
3、RF遠端連線oracle
測試套上匯入所需library:
關鍵字連線oracle資料庫:
引數詳解:連線資料庫:Connect To Database Using Custom Params;需要傳入2個引數;cx_Oracle和資料庫連線資訊-- '賬號','密碼','ip:埠/ORCL'
例子:
執行結果:
常見問題:
查詢結果亂碼問題:http://blog.sina.com.cn/s/blog_71bc9d680102x1i7.html
Unable to acquire Oracle environment handle:拷貝oci.dll, oraociei10.dll, oraocci10.dll到site-package中,問題解決。
DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded:下載個64位的instantclient-basic,然後解壓,配置64位的路徑到系統環境變數Path,重新執行python指令碼即可。
DatabaseError: ORA-12154 TNS: 無法解析指定的連線識別符號,Connect To Database Using Custom Params的引數填寫錯誤。
版權宣告:本文為博主原創文章,未經博主允許不得轉載。
https://blog.csdn.net/ChenLeihappy/article/details/79911198