RF:connecting to multiple databases
2024-08-29 11:11:53
Hello,
I am trying to connect to multiple databases with DatabaseLibrary but its not working.
*** Settings ***
Library DatabaseLibrary WITH NAME db1
Library DatabaseLibrary WITH NAME db2
*** Keywords ***
connect db1 database
db1.Connect To Database Using Custom Params cx_Oracle 'db1 connection string'
@{queryResults1}= db1.Query select * from db1_table --> OK
db2.Connect To Database Using Custom Params cx_Oracle 'db2 connection string'
@{queryResults1}= db2.Query select * from db2_table --> also OK
@{queryResults1}= db1.Query select * from d1table --> fails saying that db1_table does not exist
==============================
You did not specify which DatabaseLibrary you are talking about, but they both appear to have the same design flaw.
They both have a test library scope of GLOBAL.
RF will not create another instance of a library that is scoped GLOBAL. From the user guide, this appears to be by design.
In other words both db1 and db2 reference the same instance of DatabaseLibrary.
To fix, do all your queries in db1, then disconnect and connect to db2 and do all your queries there, etc.
If you want to do queries in both databases without (dis)connecting, there is a fairly easy way with the Python version.
Create a custom library as below:
----start content of DatabaseLibrarySS.py----
from DatabaseLibrary import DatabaseLibrary
class DatabaseLibrarySS(DatabaseLibrary):
ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
----end content of DatabaseLibrarySS.py----
*** Settings ***
Library DatabaseLibrarySS.py WITH NAME db1
Library DatabaseLibrarySS.py WITH NAME db2
*** Test Cases ***
Multiple Instances of DatabaseLibrary
${db1}= Get Library Instance db1
${db2}= Get Library Instance db2
Should Not Be Equal ${db1} ${db2}
A library with a scope of GLOBAL should implement keywords to make concurrent use from different contexts possible. For examples, see Switch Process in OperatingSystem or Switch Browser in Selenium2Library.
what am i doing wrong here?
Thanks in advance for your time and help.
最新文章
- Create Volume 操作(Part II) - 每天5分钟玩转 OpenStack(51)
- 关系数据库SQL之可编程性函数(用户自定义函数)
- iOS开发 iOS9横屏后状态栏隐藏处理
- jquery 上传图片即时预览功能
- phpexcel的写操作将数据库中的数据导入到excel中
- 企业信息系统——CRM
- iphone 使用 soap 服务 介绍
- SharpZipLib 压缩文档下载
- Delphi - SEH研究
- ng-if 和 ng-show/ng-hide 之间的区别
- 关于Javascript循环体变量声明与初始化的效率问题
- YII2框架下使用PHPExcel导出柱状图
- Linux提示字符设置
- BIO和NIO
- BZOJ.5290.[AHOI/HNOI2018]道路(树形DP)
- LOJ550 Matching 构造
- SQL行列转换6种方法
- 华为MSTP负载均衡配置示例
- find &; grep 命令 in linux(转)
- 【F12】谷歌浏览器F12前端调试工具 Console
热门文章
- Firefox中有时使用window.close()脚本无法关闭当前窗口
- No qualifying bean of type 'org.springframework.ui.Model' available
- JS监听手机物理返回键,返回到指定页面
- PHP几个快速读取大文件例子
- Linux 命令 - mknod
- 2017 青岛网络赛 Chenchen, Tangtang and ZengZeng
- winodws系统搭建git服务--Tomcat--jdk配置
- flask-Bootstrap Jinja2 原生 模板 和 jumpserver 模板
- 洛谷 P4391 [BOI2009]Radio Transmission 无线传输
- DB2的常用指令