{"id":6224,"library":"robotframework-databaselibrary","title":"Database Library for Robot Framework","description":"The Database Library for Robot Framework allows users to query databases and verify results within Robot Framework tests. It is currently at version 2.4.1 and maintains an active release cadence, with frequent minor and patch updates to introduce new features, fix bugs, and enhance compatibility.","status":"active","version":"2.4.1","language":"en","source_language":"en","source_url":"https://github.com/MarketSquare/Robotframework-Database-Library","tags":["robotframework","database","testing","automation","sql"],"install":[{"cmd":"pip install robotframework-databaselibrary","lang":"bash","label":"Core library"},{"cmd":"pip install sqlparse","lang":"bash","label":"Optional for advanced SQL string splitting"},{"cmd":"pip install pymysql","lang":"bash","label":"Example: MySQL driver"}],"dependencies":[{"reason":"The core framework this library extends.","package":"robotframework","optional":false},{"reason":"Optional external parser for splitting SQL strings in keywords like 'Execute SQL String' and 'Split SQL String' (v2.2.0+).","package":"sqlparse","optional":true},{"reason":"A database-specific Python driver (e.g., pymysql, psycopg2, oracledb, ibm_db, pyodbc, or built-in sqlite3) is required to connect to actual databases. This library acts as a wrapper.","package":"any Python DB API 2.0 compliant driver","optional":false}],"imports":[{"note":"Imported directly in Robot Framework Settings table.","symbol":"DatabaseLibrary","correct":"Library    DatabaseLibrary"}],"quickstart":{"code":"*** Settings ***\nLibrary    DatabaseLibrary\n\n*** Test Cases ***\nExample Database Interaction\n    Connect To Database    sqlite3    :memory:\n    Execute SQL String    CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)\n    Execute SQL String    INSERT INTO users (name) VALUES ('Alice')\n    Execute SQL String    INSERT INTO users (name) VALUES ('Bob')\n    ${result}=    Query    SELECT name FROM users WHERE id = 1\n    Check Query Result    SELECT name FROM users WHERE id = 1    equals    Alice\n    Check Row Count    SELECT * FROM users    ==    2\n    Disconnect From Database\n","lang":"robotframework","description":"This example demonstrates connecting to an in-memory SQLite database, creating a table, inserting data, querying it, and asserting results using various keywords. It highlights the basic workflow without requiring external database setup beyond the library itself, as `sqlite3` is a built-in Python module."},"warnings":[{"fix":"Migrate to `Check Row Count` with the assertion engine, for example: `Check Row Count    SELECT id FROM person WHERE first_name = 'Franz Allan'    >=    1`.","message":"Keywords `Check If Exists In Database` and `Check If Not Exists In Database` are deprecated and will be removed in future versions.","severity":"deprecated","affected_versions":"2.0+"},{"fix":"Ensure the required database driver is installed via pip before using `Connect To Database`.","message":"The library itself does NOT include database drivers. You must manually install the appropriate Python DB API 2.0 compliant driver (e.g., `pip install pymysql` for MySQL, `pip install psycopg2` for PostgreSQL) for the database you intend to connect to.","severity":"gotcha","affected_versions":"All"},{"fix":"Update your Robot Framework test files to use the new parameter names.","message":"Several parameters were renamed in version 2.0, notably `sqlScriptFileName` to `sql_script_file` and `sansTran` to `no_transaction`.","severity":"breaking","affected_versions":"2.0+"},{"fix":"For versions 2.3.2 and later, use the `assert_as_string=True` parameter in `Check Query Result` to ensure all comparisons are made as strings. Alternatively, cast values in your SQL query to match expected types.","message":"When using `Check Query Result`, type mismatch issues can occur if comparing numeric database results (e.g., INTEGER) directly with string literals from Robot Framework.","severity":"gotcha","affected_versions":"<2.3.2, and 2.3.2+ if `assert_as_string` is not used"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}