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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/flygxx/article/details/79163538

这两天捣鼓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'   

猜你喜欢

转载自blog.csdn.net/flygxx/article/details/79163538