Skip to content

Commit 5f50920

Browse files
committed
Add example with aliases into readme
1 parent abca110 commit 5f50920

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

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.

0 commit comments

Comments
 (0)