我想通过Python脚本连接到Oracle数据库。为此,我正在尝试安装cx_oracle Python模块。Oracle没有安装在我的Linux机器上。
在安装cx_oracle模块时,它会引发错误,指出“无法定位Oracle软件安装”
是否有任何方法可以通过python连接到Oracle DB,而无需在Linux框中安装Oracle。
-bash-4.1$ pip install cx_Oracle
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting cx_Oracle
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached cx_Oracle-5.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-PUb2Gy/cx-Oracle/setup.py", line 174, in <module>
raise DistutilsSetupError("cannot locate an Oracle software " \
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PUb2Gy/cx-Oracle/
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning发布于 2017-07-17 22:47:02
如果只是为了避免不受支持的软件带来的安全问题,我肯定会建议升级Python安装。您可以从https://www.python.org/downloads下载一个新版本。根据您的操作系统,可能有安装Python替代版本的方法。
然而,Python2.6仍然是可能的。如果使用OracleLinux6或RHEL 6,可以从这里下载RPM。
如果需要从源代码构建,最简单的解决方案是使用cx_Oracle 6和pip一起使用以下命令:
pip install cx_Oracle --upgrade --precx_Oracle 6编译时不需要安装Oracle,但cx_Oracle 5和更早版本需要安装。
在运行时,所有版本的cx_Oracle都需要甲骨文客户端.安装最简单的是Oracle客户机,您可以找到这里。
发布于 2017-09-14 12:44:46
sqlplus_commando可能确实是您所需要的。
您可以在代码中使用此驱动程序,如下所示:
from sqlplus_commando import SqlplusCommandosqlplus =SqlplusCommando(主机名=‘localhost’,数据库=‘test’,用户名=‘test’,密码=‘test’)结果=sqlplus.run_query(“选择42作为响应,‘这是一个测试’作为来自DUAL的问题;”)打印结果
https://stackoverflow.com/questions/44957342
复制相似问题