• python cx_Oracle os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'


    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import cx_Oracle
    from pprint import pprint
    import csv
    import time
    import re
    import binascii
    print time.ctime()
    try:
     conn = cx_Oracle.connect('tlcbuser/tlcbuser@10.5.100.232/tlyy')
    # cursor = conn.cursor()
    # xsql="select * from tlcb_mon_device a where a.ipaddr='10.3.244.1'"
    # r = cursor.execute(xsql)
    # print r
    except Exception,e:
     print e
     print type(e)
     print str(e).decode('UTF-8').encode('GBK')
     print time.ctime()
     
     
     C:Python27python.exe C:/Users/tlcb/PycharmProjects/untitled/a6.py
    Mon Oct 22 10:35:59 2018
    ORA-12170: TNS: ���ӳ�ʱ
    <class 'cx_Oracle.DatabaseError'>
    Mon Oct 22 10:36:20 2018
    
    Process finished with exit code 0
    
    
    
    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import cx_Oracle
    from pprint import pprint
    import csv
    import time
    import re
    import binascii
    import os
    os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
    print time.ctime()
    try:
     conn = cx_Oracle.connect('tlcbuser/tlcbuser@10.5.100.232/tlyy')
    # cursor = conn.cursor()
    # xsql="select * from tlcb_mon_device a where a.ipaddr='10.3.244.1'"
    # r = cursor.execute(xsql)
    # print r
    except Exception,e:
     print e
     print type(e)
     print time.ctime()
     
     
     
     C:Python27python.exe C:/Users/tlcb/PycharmProjects/untitled/a6.py
    Mon Oct 22 10:44:20 2018
    ORA-12170: TNS: 连接超时
    <class 'cx_Oracle.DatabaseError'>
    Mon Oct 22 10:44:41 2018
    
    Process finished with exit code 0
    
  • 相关阅读:
    mysql-community-server-5.7.24 & 5.7.31 (5.6.35 升级到 5.7.24)
    企业 数据 能力 中台 大数据平台 CRM
    Tomcat日志切割配置
    你不知道的 Blob
    细说websocket快速重连机制
    DNS反向查询
    从安全的角度看待DNS
    LVS 负载均衡集群
    Linux服务器配置DNS解析
    react修改state的值
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349020.html
Copyright © 2020-2023  润新知