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