• python 连接oracle报错


    # !/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()
    conn = cx_Oracle.connect('test/test@10.10.17.200/serv')
    print '--------conn-------------'
    print conn
    print type(conn)
    print '--------conn-------------'
    cursor = conn.cursor()
    print '--------cursor------------'
    print cursor
    print type(cursor)
    print '--------cursor------------'
    def get_sql():
     xsql="select 'aaa' from dual"
     cursor.execute(xsql)
     result = cursor.fetchall()
     print result
    while True:
        print '--------conn-------------'
        print conn
        print type(conn)
        print '--------conn-------------'
        cursor = conn.cursor()
        print '--------cursor------------'
        print cursor
        print type(cursor)
        print '--------cursor------------'
        get_sql()
        time.sleep(2)
        
        
    
    
    
    --------conn-------------
    <cx_Oracle.Connection to test@10.10.17.200/serv>
    <type 'cx_Oracle.Connection'>
    --------conn-------------
    --------cursor------------
    <cx_Oracle.Cursor on <cx_Oracle.Connection to test@10.10.17.200/serv>>
    <type 'cx_Oracle.Cursor'>
    --------cursor------------
    [('aaa',)]
    --------conn-------------
    <cx_Oracle.Connection to test@10.10.17.200/serv>
    <type 'cx_Oracle.Connection'>
    --------conn-------------
    --------cursor------------
    <cx_Oracle.Cursor on <cx_Oracle.Connection to test@10.10.17.200/serv>>
    <type 'cx_Oracle.Cursor'>
    --------cursor------------
    [('aaa',)]
    
     
     
     关闭数据库:
     
     <type 'cx_Oracle.Cursor'>
    --------cursor------------
    Traceback (most recent call last):
      File "C:/Users/tlcb/PycharmProjects/untitled/rizhiyi/a7.py", line 37, in <module>
        get_sql()
      File "C:/Users/tlcb/PycharmProjects/untitled/rizhiyi/a7.py", line 24, in get_sql
        cursor.execute(xsql)
    cx_Oracle.OperationalError: ORA-03113: 通信通道的文件结尾
    进程 ID: 2909
    会话 ID: 575 序列号: 149
    
    Process finished with exit code 1
    
    关闭数据库直接报错
    
    
    
    
    # !/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()
    conn = cx_Oracle.connect('test/test@10.10.17.200/serv')
    print '--------conn-------------'
    print conn
    print type(conn)
    print '--------conn-------------'
    cursor = conn.cursor()
    print '--------cursor------------'
    print cursor
    print type(cursor)
    print '--------cursor------------'
    def get_sql():
     xsql="select 'aaa' from dual"
     cursor.execute(xsql)
     result = cursor.fetchall()
     print result
    while True:
        get_sql()
        time.sleep(2)
        
        
    
    # !/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()
    conn = cx_Oracle.connect('test/test@10.10.17.200/serv')
    print '--------conn-------------'
    print conn
    print type(conn)
    print '--------conn-------------'
    cursor = conn.cursor()
    print '--------cursor------------'
    print cursor
    print type(cursor)
    print '--------cursor------------'
    def get_sql():
     xsql="select 'aaa' from dual"
     cursor.execute(xsql)
     result = cursor.fetchall()
     print result
    while True:
        try:
         get_sql()
         time.sleep(2)
        except Exception,e:
         print e
         
         
    ORA-03114: 未连接到 ORACLE
    ORA-03114: 未连接到 ORACLE
    ORA-03114: 未连接到 ORACLE
    ORA-03114: 未连接到 ORACLE
    ORA-03114: 未连接到 ORACLE
    ORA-03114: 未连接到 ORACLE
  • 相关阅读:
    Linux-shell-算术运算{expr、bc、dc、(( ))和[ ]}
    [SHELL]:let 命令详解
    23-tcp协议——TIME_WAIT状态和FIN_WAIT2状态
    ethtool -p eth0 物理口一个灯在不停的闪烁
    PXE
    UID, EUID, SUID, FSUID
    echo $[1 + 2] shell中 $[] 在bash中同$(()),用于算术计算
    Cocos2d入门--3-- 向量的应用
    Cocos2d入门--2-- 三角函数的应用
    Cocos2d入门--1-- 初涉相关属性或代码
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349018.html
Copyright © 2020-2023  润新知