Created
November 21, 2013 23:06
-
-
Save ivanelson/7591481 to your computer and use it in GitHub Desktop.
Connect Oracle with Python + Apache CGI + cx_Oracle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ?