No module named 'cx_Oracle' - Python

0

Hello, good afternoon.

I'm trying to make a connection to the oracle database, but when I run my script it gives this error of No module named 'cx_Oracle'. But I have this installed on the machine and I'm using python 3.6. Does anyone know how to fix this?

import cx_Oracle
uid = "user"    # usuário
pwd = "pwd"   # senha
db = "(DESCRIPTION =    (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = UBR001001-125)(PORT = 1521)))(CONNECT_DATA=(SID=corps0)))  "  #string de conexão do Oracle, configurado no 
                # cliente Oracle, arquivo TNSNAMES.ORA

connection = cx_Oracle.connect(uid+"/"+pwd+"@"+db) #cria a conexão
cursor = connection.cursor() # cria um cursor

cursor.execute("SELECT * FROM TAB") # consulta sql
result = cursor.fetchone() # busca o resultado da consulta
if result == None:
    print ("Nenhum Resultado")
    exit
else:
    while result:
        print (result[0])
        result = cursor.fetchone()

cursor.close()
connection.close()

This is the code I'm trying to execute. My cx_Oracle is version 7.0 and I already have the environment variable set.

    
asked by anonymous 21.12.2018 / 19:56

0 answers