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

首頁 > 開發 > Python > 正文

python使用 cx

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

本文實例講述了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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新兴县| 迁安市| 九江县| 木里| 大庆市| 龙井市| 海盐县| 新绛县| 东宁县| 绥滨县| 老河口市| 静安区| 四子王旗| 荆门市| 五河县| 呼玛县| 诏安县| 临安市| 邯郸市| 通江县| 宣威市| 准格尔旗| 大宁县| 周口市| 丹巴县| 铁岭市| 玛多县| 土默特左旗| 高陵县| 海安县| 龙井市| 梓潼县| 沙田区| 随州市| 贺州市| 青田县| 故城县| 仲巴县| 弥勒县| 东安县| 广平县|