Python之Oracle

小刀试牛,连接了下Oracle;

准备:JDK1.6\ Myeclipse\ Oracle客户端\ cx_Oracle

 

代码如下:

 

 

import cx_Oracle

try:
#    con = cx_Oracle.connect("ljxt/[email protected]:1521/dtht")
    con = cx_Oracle.connect("ljxt","ljxt","192.168.0.2:1521/dtht")
    print "The Database Version ",con.version 
    cur = con.cursor()
    cur.execute("select * from LJ_SW_PERSONINFO")
    for tmp in cur:
        print tmp
    cur.close()
    con.close()
except Exception as e:
    print "failed to connected server"

 

 

原来这个是调用Oracle的OCI来连接数据库;

 

 

(2, -1, '????1', '????1', '1', 'man', datetime.datetime(2004, 8, 2, 0, 0), '1', '1', '1', '1', '1', '1', '1', 'weihun', '1', '1', '1', '1', '1', '1', 28, None, 26, '???', '??2', '?????', datetime.datetime(2011, 8, 10, 13, 50, 51), 1, None, None, datetime.datetime(2011, 9, 1, 0, 0), 1, 0, '??', 'wuye', None, 1, None)
(6, -1, '??', None, '1', '-1', datetime.datetime(2011, 9, 9, 0, 0), '-1', '-1', '-1', '-1, -1, -1', None, None, None, 'weihun', None, None, None, None, '1', None, 28, None, 26, '???', 'bb', '?????', datetime.datetime(2011, 8, 30, 11, 34, 49), 1, datetime.datetime(2011, 9, 19, 14, 6, 22), 1, None, None, 0, ';;;', 'wuye', None, 1, None)
(5, -1, '??', '???', '0', '1', datetime.datetime(1980, 9, 21, 0, 0), 'jixiao', 'qunzhong', 'beijing', 'hebei, hebei, -1, -1, hebei, -1', '?????', '?????', '???', 'weihun', '11012301239', '????', None, '???', '1', '1211111', 28, None, 26, '???', 'bb', '?????', datetime.datetime(2011, 8, 26, 11, 57, 21), 1, datetime.datetime(2011, 8, 31, 17, 39, 41), 1, datetime.datetime(2011, 8, 26, 0, 0), 1, 0, '??', 'nongmin', None, 1, None)
(13, 5, 

你可能感兴趣的:(Python之Oracle)