sql >> Database >  >> RDS >> Oracle

Python Oracle DB Connect zonder Oracle Client

U kunt JDBC gebruiken

"""
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. Converteer 'datetime2' naar 'datetime' in SQL Server (T-SQL-voorbeelden)

  2. Invoegen in tabel vanuit Array PHP

  3. Het implementeren van Twitter en Facebook-achtige hashtags

  4. Hoe arrays samen te voegen met MySQL vanuit 3 tabellen met veel-op-veel-relaties