Database is a library for handling different database operations.

All database operations are supported. Keywords Query and Get Rows return values by default in RPA.Table format.

Library is compatible with any Database API Specification 2.0 module.

References:

Examples

Robot Framework

*** Settings ***
Library         RPA.Database

*** Tasks ***
Get Orders From Database
    Connect To Database  pymysql  tester  user  password  127.0.0.1
    @{orders}            Query    Select * FROM incoming_orders
    FOR   ${order}  IN  @{orders}
        Handle Order  ${order}
    END

Python

from RPA.Database import Database
from RPA.Robocloud.Secrets import FileSecrets

filesecrets = FileSecrets("secrets.json")
secrets = filesecrets.get_secret("databasesecrets")

db = Database()
db.connect_to_database('pymysql',
                    secrets["DATABASE"],
                    secrets["USERNAME"],
                    secrets["PASSWORD"],
                    '127.0.0.1'
                    )
orders = db.query("SELECT * FROM incoming_orders")
for order in orders:
    print(order)