20180125 Python flask+oracle遇到的问题和处理方案

这两天捣鼓python的flask框架遇到点问题,以及相关处理方案,以此记录。

1.连接oracle,出现cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: “
解决办法: 参照 https://oracle.github.io/odpi/doc/installation.html#windows

1.Download an Oracle 11.2, 12.1 or 12.2 “Basic” or “Basic Light” zip file: 64-bit or 32-bit, matching your application architecture.
2.Unzip the package into a single directory that is accessible to your application, for example C:\oracle\instantclient_12_2.
3.Set the environment variable PATH to include the path that you created in step 2. For example, on Windows 7, update PATH in Control Panel -> System -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> PATH.
4.If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml with Instant Client, then create a network\admin subdirectory, for example C:\oracle\instantclient_12_2\network\admin.
    This is the default Oracle configuration directory for applications linked with this Instant Client.
    Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

2.python oracle查询中文乱码(问号)问题
解决方案:
用的是sqlalchemy,在测试机器上部署查询中文为”?”,简单设置如下:

# -*- coding: utf-8 -*-  
import os   
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'   
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值