DatabaseLibrary

Scope: global
Named arguments: supported

Introduction

Database Library contains utilities meant for Robot Framework's usage.

This can allow you to query your database after an action has been made to verify the results.

This is compatible* with any Database API Specification 2.0 module.

References:

+ Database API Specification 2.0 - http://www.python.org/dev/peps/pep-0249/

+ Lists of DB API 2.0 - http://wiki.python.org/moin/DatabaseInterfaces

+ Python Database Programming - http://wiki.python.org/moin/DatabaseProgramming/

Notes:

compatible* - or at least theoretically it should be compatible. Currently tested only with postgresql (using psycopg2).

Shortcuts

Check If Exists In Database  ·  Connect To Database  ·  Disconnect From Database  ·  Query

Keywords

Keyword Arguments Documentation
Check If Exists In Database selectStatement Check if any row would be returned by given the input selectStatement. If there are no results, then this will throw an AssertionError.
Connect To Database dbapiModuleName, dbName, username, password Loads the DB API 2.0 module given dbapiModuleName then uses it to connect to the database using dbName, username, and password.
Disconnect From Database Disconnects from the database.
Query selectStatement Uses the input selectStatement to query for the values that will be returned as a list of tuples.

Tip: try specifying the column names in your select statements as much as possible to prevent any unnecessary surprises with schema changes and to easily see what your [] indexing is trying to retrieve (i.e. instead of "select * from my_table", try "select id, col_1, col_2 from my_table").