Skip to content

Instantly share code, notes, and snippets.

@vjonatan
Forked from 1N0T/oracleSQL.py
Created June 18, 2019 11:33
Show Gist options
  • Save vjonatan/49b0c787ce74741b9c3e95526b02ed4b to your computer and use it in GitHub Desktop.
Save vjonatan/49b0c787ce74741b9c3e95526b02ed4b to your computer and use it in GitHub Desktop.
(Python) Ejemplo de conexión con BBDD Oracle utilizando Python y cx_Oracle
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Requerimientos para que funcione
# sudo pip install cx_Oracle
# sudo dnf install oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
# sudo dnf install libaio
# export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH
#
import cx_Oracle
connection = cx_Oracle.connect("USER", "PASSWORD", "SERVER/SID")
cursor = connection.cursor()
cursor.execute("""
SELECT id,
descripcion
FROM actividades
WHERE familia = :family""",
family = 'AP')
for id, descripcion in cursor:
print("Values:", id, descripcion)
cursor.close()
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment