使用python连接Oracle数据库不工作

问题描述 投票:0回答:1

我试图在python中使用cx_Oracle连接到oracle数据库。但是我卡在了下面的错误中。

enter image description here

参考我的代码

  def runQuery(self,query):
        with cx_Oracle.connect(config.username,config.password,config.dsn,encoding=config.encoding) as connection:
            try:
                print(connection.version)
            except cx_Oracle.Error as error:
                print(error)

配置文件

username = 'dummy'
password = 'dummy'
dsn = 'dummy@//localhost:1521/ORCLCDB.localdomain'
port = 1512
encoding = 'UTF-8'

为了补充知识,使用oracle数据库的docker镜像来实现。

我想知道如何能清除这个问题并进行下去,谁能帮我找到我的实现中缺少的东西。

python-3.x oracle ubuntu-18.04 cx-oracle
1个回答
2
投票

你安装了Oracle Instant Client吗?看起来你使用的是Ubuntu。对于一个基于RPM的发行版,安装将 这样. 在Ubuntu上也有安装Oracle Instant Client的说明,但也许你最好把你的Python代码和cx_Oracle也放在一个容器里,就如 克里斯-琼斯在此解释.

© www.soinside.com 2019 - 2024. All rights reserved.