Skip to content

Commit

Permalink
Merge pull request #196 from MarketSquare/aliased_connection
Browse files Browse the repository at this point in the history
Allow for concurrent connections with aliases
  • Loading branch information
amochin authored Nov 18, 2023
2 parents 9c99cd6 + 3721d08 commit f368032
Show file tree
Hide file tree
Showing 14 changed files with 599 additions and 301 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ build/
.py*/
**/my_db_test.db
logs
**/output.xml
**/interactive_console_output.xml
**/log.html
**/report.html
interactive_console_output.xml
log.html
output.xml
report.html
venv
.runNumber
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Here you can find the [keyword docs](http://marketsquare.github.io/Robotframewor
```
pip install robotframework-databaselibrary
```
# Usage example
# Usage examples
## Basic usage
```RobotFramework
*** Settings ***
Library DatabaseLibrary
Expand Down Expand Up @@ -42,6 +43,32 @@ Person Table Contains No Joe
... WHERE FIRST_NAME= 'Joe'
Check If Not Exists In Database ${sql}
```
## Handling multiple database connections
```RobotFramework
*** Settings ***
Library DatabaseLibrary
Test Setup Connect To All Databases
Test Teardown Disconnect From All Databases
*** Keywords ***
Connect To All Databases
Connect To Database psycopg2 db db_user pass 127.0.0.1 5432
... alias=postgres
Connect To Database pymysql db db_user pass 127.0.0.1 3306
... alias=mysql
*** Test Cases ***
Using Aliases
${names}= Query select LAST_NAME from person alias=postgres
Execute Sql String drop table XYZ alias=mysql
Switching Default Alias
Switch Database postgres
${names}= Query select LAST_NAME from person
Switch Database mysql
Execute Sql String drop table XYZ
```

See more examples in the folder `tests`.
# Database modules compatibility
The library is basically compatible with any [Python Database API Specification 2.0](https://peps.python.org/pep-0249/) module.
Expand Down
2 changes: 1 addition & 1 deletion src/DatabaseLibrary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DatabaseLibrary(ConnectionManager, Query, Assertion):
The library is basically compatible with any [https://peps.python.org/pep-0249|Python Database API Specification 2.0] module.
However, the actual implementation in existing Python modules is sometimes quite different, which requires custom handling in the library.
Therefore there are some modules, which are "natively" supported in the library - and others, which may work and may not.
Therefore, there are some modules, which are "natively" supported in the library - and others, which may work and may not.
See more on the [https://github.com/MarketSquare/Robotframework-Database-Library|project page on GitHub].
"""
Expand Down
260 changes: 123 additions & 137 deletions src/DatabaseLibrary/assertion.py

Large diffs are not rendered by default.

Loading

0 comments on commit f368032

Please sign in to comment.