安装前提条件:

(1).安装 instantclient-basic-nt
(2).安装 instantclient-sdk-nt
(3).安装 Microsoft Visual C++ Compiler for Python(用于编译源码)
 
安装步骤:
1.激活虚拟环境
在 Windows 上,执行以下操作:
# env\scripts\activate
2.安装 cx_oracle
进入 cx_oracle 源码解压后目录(该目录下有 setup.py 文件),执行如下操作:
# python setup.py build
python setup.py install
3.检查 cx_oracle 安装结果
执行如下命令,查看是否已安装 cx_oracle。
# pip list
随后,运行 python 执行如下代码,检查 cx_oracle 是否运行正常。
>>> import cx_Oracle
connection = cx_Oracle.connect("user", "password", "TNS")
cursor = connection.cursor()
cursor.execute("select name from v$database")
for column_1 in cursor:
    print column_1
如果 cx_oracle 运行正常,则将输出连接数据库的数据库名称。

相关文章:

  • 2022-01-10
  • 2021-05-17
  • 2021-08-25
  • 2022-12-23
  • 2021-08-19
  • 2021-04-08
  • 2021-07-23
猜你喜欢
  • 2021-09-17
  • 2021-08-09
  • 2022-03-03
  • 2021-09-28
  • 2021-05-16
  • 2021-07-11
相关资源
相似解决方案