Last active
August 29, 2019 15:16
-
-
Save 1N0T/53b33e16a9e030a13e66c7dec88546ae to your computer and use it in GitHub Desktop.
(python) Ejemplo de conexión con BBDD Oracle utilizando Python y 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
#!/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