RPA.Database
Call stored procedure with name and params.
Arguments
Argument | Type | Default value |
---|---|---|
name | str | null |
params | List[str], None | None |
sanstran | bool, None | False |
as_table | bool, None | True |
multiple | bool, None | False |
param name: | procedure name |
---|---|
param params: | parameters for the procedure as a list, defaults to None |
param sanstran: | Run the query without an implicit transaction commit or rollback if such additional action was detected. (turned off by default) |
param as_table: | If the result should be an instance of Table, otherwise a list will be returned. (defaults to True) |
param multiple: | Return results for one result set (default False) or multiple results from all result sets (set this parameter to True) |
returns: | list of results |
Usage
Connect to database using DB API 2.0 module.
Arguments
Argument | Type | Default value |
---|---|---|
module_name | str, None | None |
database | str, None | None |
username | str, None | None |
password | str, None | None |
host | str, None | None |
port | int, None | None |
charset | str, None | None |
config_file | str, None | db.cfg |
autocommit | bool, None | False |
Note. The SSL support had been added for mysql module in rpaframework==17.7.0. The extra configuration parameters can be given via configuration file. Extra parameters are:
- ssl_ca
- ssl_cert
- ssl_key
- client_flags
Example configuration file:
param module_name: | database module to use |
---|---|
param database: | name of the database |
param username: | of the user accessing the database |
param password: | of the user accessing the database |
param host: | SQL server address |
param port: | SQL server port |
param charset: | for example, "utf-8", defaults to None |
param config_file: | location of configuration file, defaults to "db.cfg" |
param autocommit: | set autocommit value for connect |
Usage
Close connection to SQL database
Usage
Execute content of SQL script as SQL commands.
Arguments
Argument | Type | Default value |
---|---|---|
filename | str | null |
sanstran | bool, None | False |
encoding | str, None | utf-8 |
param filename: | filepath to SQL script to execute |
---|---|
param sanstran: | Run the query without an implicit transaction commit or rollback if such additional action was detected. (turned off by default) |
param encoding: | character encoding of file (utf-8 by default) |
Usage
Get number of rows in a table. Conditions can be given as arguments for WHERE clause.
Arguments
Argument | Type | Default value |
---|---|---|
table | str | null |
conditions | str, None | None |
param table: | name of the SQL table |
---|---|
param conditions: | restrictions for selections, defaults to None |
returns: | number or rows |
Usage
Get rows from table. Columns and conditions can be set to filter result.
Arguments
Argument | Type | Default value |
---|---|---|
table | null | |
columns | str, None | None |
conditions | str, None | None |
as_table | bool, None | True |
param table: | name of the SQL table |
---|---|
param columns: | name of columns to return, defaults to None means that all columns are returned |
param conditions: | limiting result by WHERE clause, defaults to None |
param as_table: | if result should be instance of Table, defaults to True False means that return type would be list |
returns: | table or list based on param as_table arguement |
Usage
Execute a SQL query and optionally return the execution result.
Arguments
Argument | Type | Default value |
---|---|---|
statement | str | null |
assertion | str, None | None |
sanstran | bool, None | False |
as_table | bool, None | True |
returning | bool, None | None |
data | Dict, Tuple, None | None |
Security Warning: In order to safely include untrusted data in SQL queries it is advisable to use parameterized queries. For more information about formatting for specific databases, please see https://bobby-tables.com/python
param statement: | SQL statement to execute. |
---|---|
param assertion: | Assert on query result, row_count or columns. Works only for SELECT statements. (defaults to None) |
param sanstran: | Run the query without an implicit transaction commit or rollback if such additional action was detected and this is set to True. (turned off by default, meaning that commit is performed on successful queries and rollback on failing ones automatically) |
param as_table: | If the result should be an instance of Table, otherwise a list will be returned. (defaults to True) |
param returning: | Set this to True if you want to have rows explicitly returned (instead of the query result), False otherwise. (by default a heuristic detects if it should return or not) |
param data: | The data to use if the SQL statement is parameterized |
returns: | Fetched rows when returning is True or if the heuristic decides that the statement should return (raw rows or as Table if as_table is True), otherwise the object produced by the execution is returned. |
Examples
Robot Framework
Python