Skip to content Skip to main navigation Skip to footer

python链接Oracle数据库的方法详细实例介绍

python链接Oracle数据库是如何来实现的呢?下面的内容将会通过具体的实例来演示python链接Oracle数据库的实现方法及相关技巧:

本文实例讲述了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链接Oracle数据库就是这样,欢迎大家参考。。。。

0 Comments

There are no comments yet

Leave a comment

Your email address will not be published.