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