Database Library for Robot Framework
Project description
Robot Framework Database Library
The Database Library for Robot Framework allows you to query a database and verify the results.
It requires an appropriate Python module to be installed separately - depending on your database, like e.g. oracledb
or pymysql
.
The library consists of some keywords designed to perform different checks on your database. Here you can find the keyword docs.
Requirements
- Python
- Robot Framework
- Python database module you're going to use - e.g.
oracledb
Installation
pip install robotframework-databaselibrary
Usage examples
Basic usage
*** Settings ***
Library DatabaseLibrary
Test Setup Connect To My Oracle DB
*** Keywords ***
Connect To My Oracle DB
Connect To Database
... oracledb
... dbName=db
... dbUsername=my_user
... dbPassword=my_pass
... dbHost=127.0.0.1
... dbPort=1521
*** Test Cases ***
Person Table Contains Expected Records
${output}= Query select LAST_NAME from person
Length Should Be ${output} 2
Should Be Equal ${output}[0][0] See
Should Be Equal ${output}[1][0] Schneider
Person Table Contains No Joe
${sql}= Catenate SELECT id FROM person
... WHERE FIRST_NAME= 'Joe'
Check If Not Exists In Database ${sql}
Handling multiple database connections
*** 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 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.
Python modules currently "natively" supported
Oracle
- oracledb
- Both thick and thin client modes are supported - you can select one using the
driverMode
parameter. - However, due to current limitations of the oracledb module, it's not possible to switch between thick and thin modes during a test execution session - even in different suites.
- Both thick and thin client modes are supported - you can select one using the
- cx_Oracle
MySQL
PostgreSQL
MS SQL Server
SQLite
Teradata
IBM DB2
ODBC
Kingbase
- ksycopg2
Further references (partly outdated)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file robotframework-databaselibrary-1.4.4.tar.gz
.
File metadata
- Download URL: robotframework-databaselibrary-1.4.4.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e9cd4c96937420ed3bb5baee65c4320bbd7ecc73a0836895c2c1dd9c2a99acf |
|
MD5 | d0aa63b0072f00c56633d8e5e572c464 |
|
BLAKE2b-256 | bb2134cf363acd50986a1fb98a1df8c39bc53b2d34b654089dbe731236007b98 |
File details
Details for the file robotframework_databaselibrary-1.4.4-py3-none-any.whl
.
File metadata
- Download URL: robotframework_databaselibrary-1.4.4-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 577b1d2e4fcceb036d5cd5c9cd619950457c7491dbb6fa82e7fc089f092caad3 |
|
MD5 | 5c239f0d7781045d5860f79ed8e8d46e |
|
BLAKE2b-256 | cdd2525aa31da150426bfdadb13038995b96602c25940d42c7606d268264b052 |