I need to access a remote Oracle database during an automation process I am doing using Squish(Python). As a standalone python uses cx_oracle to access Oracle database.
-
What's the problem you're having with accessing? – Peter David Carter Nov 17 '17 at 11:52
-
I am not able to install Cx_oracle in squish – Alka Singh Nov 17 '17 at 13:53
-
Tried installing through external files. Being a fairly new tool not much was found on steps to add external module to the tool. The tool has inbuilt provision to access SQLite... Need to replicate the same by installing Oracle module – Alka Singh Nov 17 '17 at 13:58
2 Answers
Redirected Squish to use Python folders installed externally (edit python address to the external python folder in path.ini file in 'etc' folder at two locations -LibraryPath -Scripting/PythonHome ). Be sure to use external python should beexact same version as installed in your squish
Installed Oracle client 64 bit (Downloaded from oracle and add Lib path to environment variable).
Installed cx_oracle from here 'https://pypi.python.org/pypi/cx_Oracle/5.2.1'
Used the following script
import cx_Oracle
def main():
ip = 'xxxxx.xxx.xxxx.xxx'
port = xxxx
SID = 'xxxxxx'
dsn_tns = cx_Oracle.makedsn(ip, port, SID)
conn = cx_Oracle.connect('username', 'password', dsn_tns)
curs = conn.cursor()
curs.arraysize=50
curs.execute('SELECT * from tablename')
print "Student No\tModule\tMarks\n"
for column_1, column_2, column_3 in curs.fetchall():
print column_1, "\t", column_2, "\t", column_3
curs.close()
conn.close()
main()
Also, in Squish change SQUISH_DIR/lib/python*.dll
to SQUISH_DIR/lib/python*_off.dll

- 31
- 2
-
One more thing in Squish change 'SQUISH_DIR/lib/python*.dll' to 'SQUISH_DIR/lib/python*_off.dll' – Alka Singh Nov 22 '17 at 09:12
If your purpose is to execute queries/to verify values in the database for which the AUT has access already, you can insert a new special purpose method to execute SQLs (insert/update/delete, select etc.) in to the souce code of your AUT. Then, you can call these methods by creating a reference to that.
For example, getSQLResult(sql_as_a_string) will return a result set as an array, such that you can verify it in your script.

- 31
- 3