Robot Framework-databaselibaray Library use (python)

Source: Internet
Author: User

  Company to do the project used to Databaselibaray, just started to encounter a lot of problems, online also consulted a lot of information finally can be used, and now records down, there is a need for students to use:

Another, this article is mainly Databaselibaray use, the RF environment can be seen in my other article: Robot Framework Environment Construction

1, Databaselibaray Environment preparation:

A) Install cx_oracle:http://sourceforge.net/projects/cx-oracle/files/

b) Install Dblibrary:https://github.com/franz-see/robotframework-database-library

c) Install Oracle (select one of the following two):

I. Installing the Oracle client: http://www.oracle.com/

II. Installing Instant client:http://www.oracle.com/technology/global/cn/software/tech/oci/instantclient/index.html

Note: The version of Cx_oracle is consistent with the version of Oracle

second, the use of Dblibrary

    Connect to Database Using Custom Params    cx_oracle    ' Scott ', ' Tiger ', ' Oral '    @{data}     Query    SELECT * FROM dept    Log many    @{data}    log    ${data[0][1]}    ${row}    Row Count    SELECT * FROM dept    Log    ${row}    ${count}    Get length    ${data}    Log    ${count}    Execute Sql String      Delete from dept D where d.id= ' 1 '    Disconnect from database
     

Description

1. Connect to Database Using Custom Params:

A) The first parameter I'm using Cx_oracle, just write this.

b) The second parameter consists of three parts: User,pwd,tns

2, about TNS more say two words: I installed the Oracle client, you can configure your TNS in the Oracle installation directory \network\admin\tnsnames.ora, my following:

    • Oral= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST =192.168.1.10) (PORT = 1526)) (Connect_data = (sid =oral)))

Because my Tnsnames.ora file is configured with TNS, it can be used directly with its SID, which is oral. If not configured, use directly (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST =192.168.1.10) (PORT = 1526)) (Connect_data = (SID =oral)) instead of the upper The oral is also possible in the case of polygons.

Iii. obstacles encountered and solutions:

Use dblibrary at home without any problems, but to the company when the problem, mainly has the following two questions, tossing for a long time:

1. Importerror:dll load failed: This problem can be solved by copying oci.dll to Python's lib\site-packages directory.

2. interfaceerror:unable to acquire Oracle environment handle: This issue requires a copy of another two DLLs: oraocci11.dlL and Oraociei11.dll

Reference:

Http://www.51testing.com/html/15/246015-853524.html

Http://blog.sina.com.cn/s/blog_654c6ec70100u9fr.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.