国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Python > 正文

python使用 cx

2024-09-09 19:03:02
字體:
來源:轉載
供稿:網友

本文實例講述了python使用 cx_Oracle 模塊進行查詢操作。分享給大家供大家參考,具體如下:

# !/usr/bin/env python# -*- coding: utf-8 -*-import cx_Oraclefrom pprint import pprintimport csvimport timeimport reimport binasciiprint 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 rexcept Exception,e: print e print type(e) print str(e).decode('UTF-8').encode('GBK') print time.ctime()

C:/Python27/python.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_Oraclefrom pprint import pprintimport csvimport timeimport reimport binasciiimport osos.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 rexcept Exception,e: print e print type(e) print time.ctime()

C:/Python27/python.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

# !/usr/bin/env python# -*- coding: utf-8 -*-import cx_Oraclefrom pprint import pprintimport csvimport timeimport reimport binasciiimport osos.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'print time.ctime()conn = cx_Oracle.connect('test/test@10.10.17.200/serv')cursor = conn.cursor()xsql="select 'aaa' from dual"cursor.execute(xsql)result = cursor.fetchall()print result

C:/Python27/python.exe C:/Users/tlcb/PycharmProjects/untitled/rizhiyi/a7.py
Mon Oct 22 11:33:52 2018
[('aaa',)]
 
Process finished with exit code 0

更多關于Python相關內容感興趣的讀者可查看本站專題:《Python常見數據庫操作技巧匯總》、《Python編碼操作技巧總結》、《Python數據結構與算法教程》、《Python Socket編程技巧總結》、《Python函數使用技巧總結》、《Python字符串操作技巧匯總》、《Python入門與進階經典教程》及《Python文件與目錄操作技巧匯總》

希望本文所述對大家Python程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长沙市| 淮滨县| 通州市| 两当县| 英山县| 呼伦贝尔市| 珠海市| 张家界市| 罗平县| 富蕴县| 壶关县| 雅江县| 邹平县| 新竹县| 临高县| 定州市| 尤溪县| 屯昌县| 大渡口区| 壶关县| 康乐县| 乐业县| 奇台县| 吴桥县| 镇远县| 获嘉县| 乌兰察布市| 石渠县| 墨江| 都江堰市| 永春县| 石城县| 贵德县| 宣城市| 华蓥市| 重庆市| 洱源县| 桐城市| 张家口市| 吉木乃县| 东兴市|