I tried to use cx_Oracle, but I couldn't install it, I have this message error : "cannot locate an Oracle software installation", and yes, I don't have an Oracle server on my PC, I just have sqlDeveloper to test my queries. But I would like to make some queries with robot Framework on this distant database, is this possible?
-
Are you using windows or linux machine to run the test cases? – Deepti K Dec 09 '15 at 13:37
-
windows, but I solved my problem by using the installer instead of pip. – françois Gagneau Dec 10 '15 at 08:53
4 Answers
I successfully use cx_Oracle to access an Oracle database using the DatabaseLibrary. On a Windows platform, you
- install the thin client
- to the system PATH, add the path to the instant client folder
- install cx_Oracle
Connecting to the database for our setup looks like this:
Connect To Database Using Custom Params cx_Oracle user='bob', password='letmein', dsn='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=sql1.mycompany.com)(PORT=1521)))(CONNECT_DATA=(SID=warehouse)))'

- 2,344
- 15
- 21
-
I downloaded instantclient-basic-windows, set the system PATH, but now I have this message error when I try to install cx_Oracle : "distutils.errors.DistutilsSetupError: cannot locate Oracle include files in C:\instantclient_folder" Any Ideas? – françois Gagneau Dec 07 '15 at 11:38
-
I think you downloaded a different package/version of instant client than is required. See http://stackoverflow.com/a/31308099/2532697 – ombre42 Dec 07 '15 at 14:58
-
The above link suggests downloading instantclient-basic-nt, but I have been using instantclient-basiclite-nt successfully so either will probably do. – ombre42 Dec 07 '15 at 15:02
-
thank you , I don't know if it was a version problem because I tried several and it did not work, I still had the same message. I didn't mentioned that I used pip install, I tried to use the installer and it worked. So finally I think the solution was to use the installer, if you can change your answer by adding "also try to use the installer" or something like this, I could validate your answer. Now, there is a new problem, my request returns only cx_Oracle.OBJECT, so it's an another topic. – françois Gagneau Dec 10 '15 at 08:51
Install miniconda python distribution which makes it much easier. It comes with conda package manager as alternative to pip. Installing cx_oracle including instant client is then just this easy:
conda install oracle-instantclient
conda install cx_oracle
It will automatically download matching DLL files and place it to condo root directory. This way you do not have to stuggle with ORACLE_HOME
, PATH
variables and 32-bit vs. 64-bit mismatch of python and oracle DLL drivers.
Using it in robotframework example:
*** Settings ***
Documentation Basic database related keywords
Library DatabaseLibrary
*** Variables ***
${DB_CONNECT_STRING} = 'user/mypasswd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myipaddress)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=mysid)))'
*** Keywords ***
Connect
connect to database using custom params cx_Oracle ${DB_CONNECT_STRING}
Disconnect
disconnect from database

- 147
- 1
- 5
Yes it is possible.
2 solutions:
use odbc drivers and pyodbc
use jtds drivers and jaydebeapi:
${jdbcDriver} Set Variable '${jdbcDriversPath}/ojdbc6.jar' Connect To Database Using Custom Params jaydebeapi 'oracle.jdbc.driver.OracleDriver', ['jdbc:oracle:thin:@//${DB_HOST}:${DB_PORT}/${DB_SSID}','${database}','${DB_PASSWORD}'],${jdbcDriver}

- 437
- 2
- 11
Installing the 32-bit versions of the following solved the issue for me:
- Instant Client Package - Basic
- Instant Client Package - SDK
I don't know for what reason but 64-bit versions of the Oracle client didn't work for me.

- 104
- 3