python链接Oracle数据库的方法

yipeiwu_com5年前Python基础

本文实例讲述了python链接Oracle数据库的方法。分享给大家供大家参考。具体如下:

这里使用python链接Oracle数据库需要引用cx_Oracle库

#coding=UTF-8
  import cx_Oracle
  def hello():
    '''Hello cx_Oracle示例:
    1)打印数据库版本信息.
    2)查询表数据.'''
    conn = cx_Oracle.connect("obs61","obs61","tx8i.hp")
    cur = conn.cursor()
    try:
      print "Oracle Version:%s" % conn.version
      print "Table SUB_POLICY rows:"
      cur.execute('select * from wlan_future_event')
      for row in cur:
        print row
    finally:
      cur.close()
      conn.close()
  hello()

希望本文所述对大家的Python程序设计有所帮助。

相关文章

Python判断Abundant Number的方法

本文实例讲述了Python判断Abundant Number的方法。分享给大家供大家参考。具体如下: Abundant Number,中文译成:盈数(又称 丰数, 过剩数abundant...

python使用matplotlib绘制柱状图教程

python使用matplotlib绘制柱状图教程

Matplotlib的概念这里就不多介绍了,关于绘图库Matplotlib的安装方法:点击这里 小编之前也和大家分享过python使用matplotlib实现的折线图和制饼图效果,感兴趣...

如何高效使用Python字典的方法详解

前言 众所周知字典(dict)对象是 Python 最常用的数据结构,社区曾有人开玩笑地说:"Python企图用字典装载整个世界",字典在Python中的重要性不言而喻,这里整理了几个关...

python实现的udp协议Server和Client代码实例

直接上代码:Server端:复制代码 代码如下: #!/usr/bin/env python # UDP Echo Server -  udpserver....

python把数组中的数字每行打印3个并保存在文档中的方法

python把数组中的数字每行打印3个并保存在文档中的方法

如下所示: arrs=[2,15,48,4,5,6,7,6,4,1,2,3,6,6,7,4,6,8] f=open('test.txt','w+') count=0 for temp...