Overview¶
Squish supports accessing databases indirectly through respective modules for the scripting languages (Python, Perl, Tcl, Ruby, except for JavaScript).
Another solution for accessing databases is to use external programs which perform the desired database accesses.
This article demonstrates using two such an external (example) programs.
Accessing databases via external tool and JDBC¶
JavaScript example¶
Step #1 - Download
JSQLExec.class
and put it into the test suite folder. (The source code for JSQLExec.class can be downloadedJSQLExec.java
.)Step #2 - Add these two functions to your JavaScript test script:
Step #3 - Create file UTF-8 encoded file
jsqlexec_select_cfg.txt
in test suite folder and make it contain the following information on the exactly line numbers as specified:Line #1:
select
- For executing SELECT statementsupdate
- For executing statements that modify the database (UPDATE, DELETE, etc.)
Line #2: JDBC driver class name
Line #3: JDBC URL
Line #4: Database user name
Line #5: Database password
Line #6: Path of UTF-8 encoded file with the database statements to be executed
Line #7: Path of UTF-8 encoded file where the results of the database statements will be written to in CSV (Comma Separated Values) format.
For example:
Step #4 - Execute SQL statement in your test script:
Python example¶
Step #1 - Download JSQLExec.class and put it into the test suite folder. (The source code for JSQLExec.class can be downloaded JSQLExec.java .)
Step #2 - Add these two imports and these two functions to your Python test script:
Step #3 - Create file UTF-8 encoded file
jsqlexec_select_cfg.txt
in test suite folder and make it contain the following information on the exactly line numbers as specified:Line #1:
select
- For executing SELECT statementsupdate
- For executing statements that modify the database (UPDATE, DELETE, etc.)
Line #2: JDBC driver class name
Line #3: JDBC URL
Line #4: Database user name
Line #5: Database password
Line #6: Path of UTF-8 encoded file with the database statements to be executed
Line #7: Path of UTF-8 encoded file where the results of the database statements will be written to in CSV (Comma Separated Values) format.
For example:
Step #4 - Execute SQL statement in your test script:
Accessing databases via external tool and Python sqlite3 module¶
Python example¶
Step 1 - Download
execute_query.py
andsquishpyutil.py
and put them into the test suite folder.Step 2 - Add these two imports and these two functions to your Python test script:
Step #3 - Execute SQL statement in your test script: