- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在 python 中使用 cx_Oracle
模块来访问远程数据库并插入或删除表中的行。顺便说一句,我已经下载了 oracle 即时客户端 11.1 以及 odbc 和 sqlplus 版本。我已将环境变量 ORACLE_HOME
和 TNS_ADMIN
设置到目录,我在那里解压缩文件并将此目录添加到 PATH
变量。当我用谷歌搜索时,我认为应该有一些 .ora
文件,但我找不到它们。
我可以从命令行使用sqlplus
命令,但我的主要问题是我无法安装和使用cx_Oracle
。我不想使用任何命令行脚本;我只想将 cx_Oracle
用作 API。
谁能给我一个完整的解释,我真的被困在那里了。这方面的所有文件都是模糊的。最好的问候。
编辑 1:
我用python setup.py install
和python setup.py build --compiler=mingw32
命令尝试了cx_Oracle
的源码包。我没有再次收到 oracle 错误,但收到了 command 'gcc' failed
错误。我尝试了 MinGW 编译器并编辑了环境变量 PATH
以包含 MinGW 安装目录(例如 C:\MinGW
);我还安装了 Microsoft Visual C++(版本 2005、2008 和 2010);但我仍然收到错误。
编辑 2:
自从 @jpmc26 提到了 tnsnames.ora
文件,我决定补充一点,我已经尝试制作一个 tnsnames.ora
和一个 sqlplus.ora
文件并将它们放在目录 C:\oracle\instant_client_11_1\network\admin
中;但是当我用谷歌搜索时,我意识到如果你使用 cx_Oracle.connect(username, password, cx_Oracle.makedsn(ip, port, sid))
命令,你可以跳过 .ora
文件。 cx_Oracle.makedsn
将生成结构本身。
最佳答案
我试了很多方法终于解决了这个问题。既然我觉得我应该写一个全面的答案,我就把我遇到的问题和解决方法分别写出来;希望它可以帮助别人。我还将问题的名称更改为适当的名称。这是我在 Windows 7 - 32 位版本中安装 cx_Oracle
模块时所经历的(我认为其他版本的 Windows 会有类似的解决方案,但我不确定):
我已经尝试使用 easy_install
安装 cx_Oracle
并且我得到了错误 No oracle client installed
。我下载了oraclebasic instant client 和 oracle sdk instant client for windows fromOracle官网,按照以下步骤安装:
Unzip oracle basic instant client into directory
C:\oracle\instant_client_11_1\
.Unzip oracle sdk instant client and copy folder
sdk
into the directoryC:\oracle\instant_client_11_1\
, consequently we have a directory asC:\oracle\instant_client_11_1\sdk\
.Add
C:\oracle\instant_client_11_1\
to the end of thePATH
environment variable.Add a new variable named
ORACLE_HOME
and setC:\oracle\instant_client_11_1\
for the value.Restart computer.
我尝试再次使用 easy_install
安装 cx_Oracle
,我得到了错误 command ‘gcc’ failed: no such file or directory
在某些情况下案例 无法找到 vcvarsall.bat
;这是因为我没有一个 C++ 编译器,所以我按照以下步骤来解决它:
Download Microsoft Visual C++ and install it.
Download MinGW and install it; note that you must install GCC module.
Add
C:\MinGW\
andC:\MinGW\bin\
(which containsgcc.exe
) to the end of thePATH
environment variable.
我尝试再次使用 easy_install
安装 cx_Oracle
,我得到了错误 command ‘gcc’ failed with exit status 1
;我试过这一步解决它:
Open file
C:\Python27\Lib\distutils\ cygwincompiler.py
and remove all–mno-cygwin
occurrences in this file; this is because recent versions ofGCC
has removed–mno-cygwin
option and it shouldn’t be there.
我尝试使用 easy_install
安装 cx_Oracle
,它成功了。
但是在网上搜索的过程中,我发现了一些可能有用的技巧:
如果你得到错误no module named win32api
,那是因为你没有你应该在你的电脑上安装 python 的 win32 扩展从 Source Forge 下载 pywin32
模块并安装它。
如果你还是没有成功,你可以尝试旧版本的cx_Oracle
;但请记住我们在以上几行中谈到的所有内容。您可以找到所有版本的 cx_Oracle
here .
如果您想使用 sqlplus
,您还应该执行其他一些步骤。为此,请搜索互联网。
关于python - 在 Windows 中部署 cx_Oracle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20472060/
我为此苦了一个星期。我正在尝试运行一个使用即时客户端版本11.2.0.3.0与远程Oracle数据库连接的python flask应用程序。 在遇到许多问题之后,我结束了使用3个buildpack,其
以下语句中字典中的 bindind 日期有问题吗?? mySQL = 'SELECT day_key FROM timeday WHERE calendar_date =:calendar' args
我尝试在 Ubuntu 上使用 crontab 运行 python scrapy 爬虫,但收到以下错误消息: Traceback (most recent call last): File "/u
我正在使用 Amazon Work Space,并且我使用 VPN 通过 SSH Ubuntu 16.04 实例进行连接。我使用 python 来连接 Oracle 数据库 11g,我需要使用 cx_
在我的 Python 代码中,当我要求用户输入一个字符串以进行 SELECT 时,它起作用了,但是当我尝试使用相同输入的 UPDATE 时,不允许我执行 这是连接成功后的代码 curs = conne
在我的 Python 代码中,当我要求用户输入一个字符串以进行 SELECT 时,它起作用了,但是当我尝试使用相同输入的 UPDATE 时,不允许我执行 这是连接成功后的代码 curs = conne
我正在尝试使用 python 中的 cx_Oracle 连接到 oracle 数据库。我能够连接到数据库并提取数据。 现在我正在尝试连接到另一个数据库,我必须首先调用安全过程,然后只有我才能看到基础表
对于我创建的 Oracle 表 MYTABLE,我有一个列 COL1,它被声明为 NUMBER(20,3);小数点后可以有 3 位有效数字。当我在此表上运行 cx_Oracle 游标时: cursor
我正在使用 web.py 从 Oracle 创建一个简单的报告页面。当我采用使用 vars= 传递参数的最佳实践方法时,延迟为 11-12 秒。当我使用字符串替换执行相同的查询时,查询会在不到一秒的时
我正在尝试在 python 中使用 cx_Oracle 并行运行完全独立的 Oracle 查询。 我可以通过为每个线程设置一个新的数据库连接,然后在每个单独的线程中运行查询来成功地完成这项工作,这使总
为什么下面的代码不起作用?它返回零行,即使我有很多匹配搜索条件的行。 select * from Table_1 形式的简单查询工作正常并返回正数行 import cx_Oracle def func
在最新版本的 python 中,可以使用类似 with open('abc.txt') as f: 的东西来保证文件被关闭,即使在以下(缩进)中发生异常) 代码块。我想知道这种技术是否也适用于 cx_
我正在使用 cx_oracle python 库来查找过去 90 分钟内具有 ModifiedDate 的任何记录。 import cx_Oracle import datetime from dat
我正在尝试连接到 Oracle 数据库,但出现以下错误: curcon = cx_Oracle.connect(conn_str) cx_Oracle.DatabaseError: ORA-12170
我正在运行... SQL*Plus: Release 9.2.X.X.X - Production on Wed Jun 22 13:02:14 2011 Copyright (c) 1982, 20
Code Oracle: Procedure example ( p_Cod_Rspta out varchar2 , p_e
在 Java DataSource 中实现了一个用于数据库访问的 Java 范例。该对象围绕数据库连接的创建创建了一个有用的抽象。 DataSource 对象保留数据库配置,但只会根据请求创建数据库连
我正在使用 cx_Oracle 访问我们的数据库。我希望用户能够输入电台 ID,例如: stationID=(无论用户在提示时输入什么) cursor.execute('''select cruise
为了演示 Oracle 的安全特性,必须在用户 session 尚未建立时调用 OCIServerVersion() 或 OCIServerRelease()。 同时具有数据库参数 sec_retur
我正尝试在 Oracle 10 数据库中再次执行此操作: cursor = connection.cursor() lOutput = cursor.var(cx_Oracle.STRING) cur
我是一名优秀的程序员,十分优秀!