-1

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.

Alka Singh
  • 31
  • 2

2 Answers2

2
  1. 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

  2. Installed Oracle client 64 bit (Downloaded from oracle and add Lib path to environment variable).

  3. Installed cx_oracle from here 'https://pypi.python.org/pypi/cx_Oracle/5.2.1'

  4. 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

Alka Singh
  • 31
  • 2
0

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.