Search code examples
pythonoracle-databasecx-oracle

Python server to Oracle database


I've been connected to Oracle DB with my local PC with below code.

con = cx_Oracle.connect("user/pw@host:port/service_name")
cur = con.cursor()

Now I can use python server, I wanted to do the same work at python server.

I'm confused whether I should install Oracle Client at Python server, as I did at my local PC. Because the same code didn't work at the python server. Error message was shown as below.

DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory".

Solution

  • I don't know what a 'Python server' is, but from the error message you need to install the 64-bit Oracle client libraries and make sure that your system library search path includes them. The message gives a link with steps that you can follow, or you can use the cx_Oracle installation instructions.

    There's an architecture diagram in the cx_Oracle documentation that may be useful.

    Was there something that was confusing in the DPI error message? Can you suggest improvements to it?