Skip to content

Commit f368032

Browse files
authored
Merge pull request #196 from MarketSquare/aliased_connection
Allow for concurrent connections with aliases
2 parents 9c99cd6 + 3721d08 commit f368032

14 files changed

Lines changed: 599 additions & 301 deletions

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ build/
66
.py*/
77
**/my_db_test.db
88
logs
9-
**/output.xml
10-
**/interactive_console_output.xml
11-
**/log.html
12-
**/report.html
9+
interactive_console_output.xml
10+
log.html
11+
output.xml
12+
report.html
1313
venv
1414
.runNumber

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Here you can find the [keyword docs](http://marketsquare.github.io/Robotframewor
1414
```
1515
pip install robotframework-databaselibrary
1616
```
17-
# Usage example
17+
# Usage examples
18+
## Basic usage
1819
```RobotFramework
1920
*** Settings ***
2021
Library DatabaseLibrary
@@ -42,6 +43,32 @@ Person Table Contains No Joe
4243
... WHERE FIRST_NAME= 'Joe'
4344
Check If Not Exists In Database ${sql}
4445
```
46+
## Handling multiple database connections
47+
```RobotFramework
48+
*** Settings ***
49+
Library DatabaseLibrary
50+
Test Setup Connect To All Databases
51+
Test Teardown Disconnect From All Databases
52+
53+
*** Keywords ***
54+
Connect To All Databases
55+
Connect To Database psycopg2 db db_user pass 127.0.0.1 5432
56+
... alias=postgres
57+
Connect To Database pymysql db db_user pass 127.0.0.1 3306
58+
... alias=mysql
59+
60+
*** Test Cases ***
61+
Using Aliases
62+
${names}= Query select LAST_NAME from person alias=postgres
63+
Execute Sql String drop table XYZ alias=mysql
64+
65+
Switching Default Alias
66+
Switch Database postgres
67+
${names}= Query select LAST_NAME from person
68+
Switch Database mysql
69+
Execute Sql String drop table XYZ
70+
```
71+
4572
See more examples in the folder `tests`.
4673
# Database modules compatibility
4774
The library is basically compatible with any [Python Database API Specification 2.0](https://peps.python.org/pep-0249/) module.

src/DatabaseLibrary/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class DatabaseLibrary(ConnectionManager, Query, Assertion):
6969
The library is basically compatible with any [https://peps.python.org/pep-0249|Python Database API Specification 2.0] module.
7070
7171
However, the actual implementation in existing Python modules is sometimes quite different, which requires custom handling in the library.
72-
Therefore there are some modules, which are "natively" supported in the library - and others, which may work and may not.
72+
Therefore, there are some modules, which are "natively" supported in the library - and others, which may work and may not.
7373
7474
See more on the [https://github.com/MarketSquare/Robotframework-Database-Library|project page on GitHub].
7575
"""

src/DatabaseLibrary/assertion.py

Lines changed: 123 additions & 137 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)