python -- 连接 orclae cx_Oracle的使用
# 如果报错参考的资料
https://blog.csdn.net/white_xuqin/article/details/82878860
场景再现:
python-cx_oracle报错"DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "
解决方案:
一、检查本地是否安装Oracle,如果安装,检查版本是否和python一样都,都是64位。
二、如果本地没有安装Oracle,则需要安装。一下为安装方式:
我们考虑安装Oracle Instant Client(轻量级客户端,占用空间极少)
安装包下载地址:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
下载instantclient-basic-windows.x64-11.2.0.4.0(或者相近的版本)即可
具体安装步骤:
1、将下载的压缩包,放到目录 E:\Oracle下,解压,生成instantclient_11_2文件夹,即:E:\Oracle\instantclient_11_2
2、修改系统变量
1> 将E:\Oracle\instantclient_11_2添加到系统变量PATH中
2> 新增系统变量
NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252 -->> 服务器端字符集
TNS_ADMIN=E:\Oracle\instantclient_11_2 -->> 指定tnsnames.ora所在位置
注意:修改系统变量之后,要检查一下是否生效,如果没有生效,则多试几次,实在不行则重启电脑。
3、在E:\Oracle\instantclient_11_2 下新建tnsnames.ora配置文件,内容如下:
orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testdb)
)
)
4、重启Pycharm(必须重启,否则还是会报错)
---------------------
作者:white_xuqin
来源:CSDN
原文:https://blog.csdn.net/white_xuqin/article/details/82878860
版权声明:本文为博主原创文章,转载请附上博文链接!
import cx_Oracle #引用模块cx_Oracle
conn=cx_Oracle.connect('账号/密码@192.168.***.***:1521/数据库名') #连接数据库 cursor = conn.cursor () try:
# 解析sql语句
# cursor.parse("select * dual")
pass
# 捕获SQL异常
except cx_Oracle.DatabaseError as e:
print(e) # ORA-: 未找到要求的 FROM 关键字 # 执行sql 语句
cursor.execute ("select * from EKP_PRODUCTIVITY_SL") for row in cursor:
print(row) c.close() #关闭cursor
conn.close()
python -- 连接 orclae cx_Oracle的使用的更多相关文章
- python -- 连接 orclae cx_Oracle的使用 二
转:https://www.cnblogs.com/cyxiaer/p/9396861.html 必需的Oracle链接库的下载地址:https://www.oracle.com/technetwor ...
- python 连接oracle -- sqlalchemy及cx_Oracle的使用详解
python连接oracle -- sqlalchemy import cx_Oracle as orcl import pandas as pd from sqlalchemy import cre ...
- python 连接 Oracle 乱码问题(cx_Oracle)
用python连接Oracle是总是乱码,最后发现时oracle客户端的字符编码设置不对. 编写的python脚本中需要加入如下几句: import os os.environ['NLS_LANG'] ...
- windows下python连接oracle数据库
1.首先安装cx_Oracle包2.解压instantclient-basic-windows.x64-11.2.0.4.0.zip到c:\oracle3.拷贝instantclient_11_2下所 ...
- Python连接Oracle数据查询导出结果
python连接oracle,需用用到模块cx_oracle,可以直接pip安装,如网络不好,可下载离线后本地安装 cx_oracle项目地址:https://pypi.org/project/cx_ ...
- python 连接 oracle 统计指定表格所有字段的缺失值数
python连接oracle -- qlalchemy import cx_Oracle as co import pandas as pd from sqlalchemy import crea ...
- Python 连接 Oracle数据库
1.环境设置 [root@oracle ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@oracle ~]# python - ...
- Python 连接Oracle数据库
连接:python操作oracle数据库 python——连接Oracle数据库 python模块:cx_Oracle, DBUtil 大概步骤: 1. 下载模块 cx_Oracle (注意版本) ...
- Python连接oracle数据库 例子一
step1:下载cx_Oracle模块,cmd--pip install cx_Oracle step2: 1 import cx_Oracle #引用模块cx_Oracle 2 conn=cx_Or ...
随机推荐
- 【LEETCODE】48、数组分类,简单级别,题目:189,217,219,268,283,414
package y2019.Algorithm.array; import java.util.Arrays; import java.util.Stack; /** * @ClassName Rot ...
- SAS学习笔记57 template的管理
template查询 首先点击SAS Windows左上方查询框,输入“odst”或者“odstemplates”,如下所示: 然后点击enter键,进入查询的template文件夹,如下所示: 这里 ...
- Python 判断字符串是否包含中文
一.摘要 使用 xlrd 模块打开带中文的excel文件时,会报错. FileNotFoundError: [Errno 2] No such file or directory: 'xx.xlsx' ...
- C#中Unity对象的注册方式与生命周期解析
1.示例代码 请详细阅读 static void Main(string[] args) { { Console.WriteLine("----------全局设置----------&qu ...
- Flutter:教你用CustomPaint画一个自定义的CircleProgressBar
https://www.jianshu.com/p/2ea01ae02ffe Flutter:教你用CustomPaint画一个自定义的CircleProgressBar paint_page.dar ...
- go语言 goquery爬虫
goquery 类似ruby的gem nokogiri goquery的选择器功能很强大,很好用.地址:https://github.com/PuerkitoBio/goquery 这是一个糗百首 ...
- Sql 按日期带条件统计
select convert(char(8),[UseTime],112) dt,sum([UseMoney]) 合计,sum(case when [S_Number]=2 then UseMoney ...
- mysql8.x 新版本jdbc连接方式
旧版本,MySQL Connector/J 5.x 版本的连接方式:url = jdbc:mysql://localhost:3306/thrcloud_db01?useUnicode=true&am ...
- UTF-8 中文编码范围
主流的匹配字符有两种 [\u4e00-\u9fa5]和[\u2E80-\u9FFF],后者范围更广,包括了日韩地区的汉字 import re pattern = re.compile("[\ ...
- Oracle数据库 常用SQL
-- 查询所有数据 SELECT * FROM [TABLE_NAME]; -- 查询数据总量 SELECT COUNT(*) AS COUNT FROM [TABLE_NAME]; -- 清空表内所 ...