Paketiek instala:
su aptitude install python-sqlalchemy alien libaio1 exit
Jakitzeko ze bertsiño dakun python-ena:
python -V
erantzune:
Python 2.7.2+
Jakitzeko oracle-n bertsiñue:
select * from product_component_version;
erantzune:
NLSRTL 11.2.0.2.0 Production Oracle Database 11g Enterprise Edition 11.2.0.2.0 64bit Production PL/SQL 11.2.0.2.0 Production TNS for 64-bit Windows: 11.2.0.2.0 Production
Nire kasuen: python 2.7 eta oracle 11.2
Orduen hurrengo web-an topa biherku paketie:
http://cx-oracle.sourceforge.net/
Nire kasuen: “Download 5.1.1 released October 10, 2011” atalien:
CentOS 5 x86_64 RPM (Oracle 11g, Python 2.7)
RPM-ie DEB-era pasateko:
su alien -d cx_Oracle-5.1-11g-py27-1.x86_64.rpm ls | grep .deb$ cx-oracle_5.1-2_amd64.deb
paketie instala
dpkg -i cx-oracle_5.1-2_amd64.deb ln -s /usr/lib/python2.7/site-packages/cx_Oracle.so /usr/lib/python2.7/dist-packages/cx_Oracle.so exit
Adibide script bet sortu
nano proba.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from sqlalchemy import create_engine connection = create_engine('oracle://USER:PASSWD@IP:PORT/DDBB').connect() result = connection.execute("select * from product_component_version") for v in result: for column, value in v.items(): print('{0}: {1}'.format(column, value)) connection.close()
Baimenak emon al izateko igiri eta ejekute:
chmod +x proba.py ./proba.py
ERROR:
ImportError: /usr/lib/python2.7/dist-packages/cx_Oracle.so: undefined symbol:PyUnicodeUCS2_AsEncodedString
Bueno hori errorie ez urteteko beste pakete bat instala dot:
“Download 5.1 released March 19, 2011” ataleko:
CentOS 5 x86_64 RPM (Oracle 11g, Python 2.7)
Desinstalateko:
su aptitude purge cx-oracle rm -rf /usr/lib/python2.7/dist-packages/cx_Oracle.so exit
eta lengo pausuek jarraitu ;)
adibide onan erantzune:
product: NLSRTL version: 11.2.0.2.0 status: Production product: Oracle Database 11g Enterprise Edition version: 11.2.0.2.0 status: 64bit Production product: PL/SQL version: 11.2.0.2.0 status: Production product: TNS for 64-bit Windows: version: 11.2.0.2.0 status: Production