Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Does Oracle have any plans on creating a standalone python driver

4203522Mar 3 2020 — edited Mar 4 2020

I've waisted many days trying to connect to oracle database on our company network in python via cx_Oracle.  I've read through many stack-exchange posts, looked at blog questions here etc.

I'll put all the details below, but before looking at that my fundamental question is why would Oracle not provide a simple standalone python driver package to connect to Oracle DBs that DOES NOT REQUIRE installing ALL OF THIS: Oracle Instant Client or Oracle database, and then having to tweak environment variables?

The motivation here is that data science very hot now and data science work uses Python as the preferred language; so why would you force everyone who wants to connect to Oracle in Python have to jump through all these gigantic ridiculous hoops just to connect to the DB?

I had to abandon connecting in Python and use Java instead for which there IS a simple standalone JDBC driver.

Here are the details of my environment:

Mac Mojave desktop computer.

Python 3.7

Oracle on network is version 11.2

I've tried following this installation: https://oracle.github.io/odpi/doc/installation.html#macos

I've tried and retried all the steps described there many times and end up with below exception at the python line: conn = cx_Oracle.connect(connection_string)

Traceback (most recent call last):

  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2060, in <module>

    main()

  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2054, in main

    globals = debugger.run(setup['file'], None, None, is_module)

  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1405, in run

    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)

  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1412, in _exec

    pydev_imports.execfile(file, globals, locals)  # execute the script

  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile

    exec(compile(contents+"\n", file, 'exec'), glob, loc)

  File "/Users/me/projdir/pymain.py", line 44, in <module>

    conn = cx_Oracle.connect(connection_string)

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): no suitable image found.  Did find:

  /Users/llnesbitt/lib/libclntsh.dylib: stat() failed with errno=20". See https://oracle.github.io/odpi/doc/installation.html#macos for help

This post has been answered by Christopher Jones-Oracle on Mar 3 2020
Jump to Answer

Comments

Answer

rqEval can accept non-numeric types as input.

In your example, 'select 1 "Industry" forces a returned numeric value.  It fails because the data returned contains 1 non-numeric column. The output doesn't match the specification in the SQL provided, and an error is returned.

Instead, use cast to return as varchar as follows:

SQL> select * from table(rqEval(

        NULL,

        'select cast(''Industry'' as varchar2(8)) "Industry" from dual',

       'Test'));

Returns:

1 Text

Marked as Answer by 3631507 · Sep 27 2020
1 - 1

Post Details

Added on Mar 3 2020
5 comments
1,141 views