RobotFramework讀取mysql和oracle資料庫

來源:互聯網
上載者:User

標籤:mysql操作   查詢   ring   image   語句   framework   ram   img   匯入   

一、robotframework串連mysql資料庫

1、安裝databaselibrary、pymysql

通過cmd命令執行:pip install robotframework-databaselibrary

cmd命令執行:pip install pymysql

2、匯入DatabaseLibrary包到Robotframework

3、使用關鍵字對資料庫進行操作

串連資料庫:Connect to database using custom params

這個關鍵字需要傳入2個參數,pymysql、及資料庫連接資訊(host=‘資料庫ip‘,port=‘資料庫連接埠‘,user=‘資料庫登陸使用者名稱‘,passwd=‘密碼‘,db=‘資料庫名(不是表名)‘)

執行查詢語句:Query

執行增刪改語句:Execute Sql String

斷開資料庫連接:Disconnect From Database

注意:sql語句結尾盡量不要用分號,每次串連資料庫後都使用斷開資料庫連接結束

 

二、robotframework串連Oracle資料庫連接

1、安裝DatabaseLibrary(見串連mysql資料庫操作)

2、安裝cx_Oracle,DatabaseLibrary,進入cx_oracle下載頁面,下載python對應的版本號碼:http://sourceforge.net/projects/cx-oracle/files/

下載完後直接安裝,安裝完成後,在你的 \Python27\Lib\site-packages目錄下,可以看到Database Library檔案夾和cx_Oracle.pyd檔案;

 

3、將本地串連oracle資料庫的oci檔案複製到site-packages目錄

4、使用關鍵字進行oracle資料庫操作

 串連資料庫:Connect To Database Using Custom Params;需要傳入2個參數;cx_Oracle和資料庫連接資訊--    ‘帳號‘,‘密碼‘,‘ip:連接埠/ORCL 

查詢和修改關鍵字跟mysql操作相同;

 

RobotFramework讀取mysql和oracle資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.