Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for concurrent connections with aliases #196

Merged
merged 15 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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