sql >> Database teknologi >  >> RDS >> Oracle

Python Oracle DB Connect uden Oracle Client

Du kan bruge JDBC

"""
Connect from Python to Oracle via JDBC
Get JDBC-driver here: https://download.oracle.com/otn/utilities_drivers/jdbc/193/ojdbc8-full.tar.gz
Python 3.7.4
conda install -c conda-forge jaydebeapi==1.1.1 --force-reinstall -y
conda install -c conda-forge JPype1==0.6.3 --force-reinstall -y
"""
import jpype
import jaydebeapi

JHOME = jpype.getDefaultJVMPath()
jpype.startJVM(JHOME, '-Djava.class.path=/ojdbc8-full/ojdbc8.jar')
con = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver',
                         'jdbc:oracle:thin:user/[email protected]_ip:1521:SID')
cur = con.cursor()
cur.execute('select dummy from dual')
r = cur.fetchall()
print(r[0][0])
cur.close()
con.close()


  1. Hvorfor ændrer DBI implicit heltal til strenge?

  2. OPDATERING med ORDER BY og LIMIT virker ikke i MYSQL

  3. Dumper SQL-forespørgsler til skærmen i Laravel

  4. Oracle + dbunit får AmbiguousTableNameException