Skip to content

Instantly share code, notes, and snippets.

@ivanelson
Created November 21, 2013 23:06
Show Gist options
  • Save ivanelson/7591481 to your computer and use it in GitHub Desktop.
Save ivanelson/7591481 to your computer and use it in GitHub Desktop.
Connect Oracle with Python + Apache CGI + cx_Oracle
#-*- encoding: utf-8 -*-
import os
os.putenv('ORACLE_HOME', '/usr/lib/oracle/11.2/client64')
os.putenv('LD_LIBRARY_PATH', '/usr/lib/oracle/11.2/client64/lib')
os.environ['ORACLE_HOME'] = "/usr/lib/oracle/11.2/client64"
os.environ['LD_LIBRARY_PATH'] = "/usr/lib/oracle/11.2/client64/lib"
import cx_Oracle
con = cx_Oracle.connect('user/pass@IPADDRESS/orcl')
version = con.version
cur = con.cursor()
cur.execute('SELECT * FROM tabalmo')
item = cur.fetchone()
#for r in cur: print r
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>.:: Oracle ::.</title>'
print '</head>'
print '<body>'
print '<h2>Oracle Conectado! Versao: %s - %s </h2>' % (version, item)
print '</body>'
print '</html>'
cur.close()
con.close()
@huarda
Copy link

huarda commented Jan 3, 2018

DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help

cx_Oracle==6.1
oracleInstance==12.1

how to solve it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment