查oracle数据及元组转字典

'''
Created on 2009-12-24

@author: jizhong.yang
'''
import cx_Oracle
import sets

myDsn = cx_Oracle.makedsn('111.111.111.111',1521,'oss32')    
conn = cx_Oracle.connect('user', 'pass', myDsn)
cur = conn.cursor()
cur.execute("select logname,dev_id from fc_lognames where rownum<10 and type='billing' and log_date='20100123'")
r = cur.fetchall()
dict = {}
print r
#for item in r:
#    list=[item[1],item[2]]
#    dict[item[0]] = list


dict = {}
dict.update(r)

print dict
#for logname in dict.keys():
#    print dict[logname][0]
#    if(dict[logname][1] not in logname):
#        print '==>'+logname
        
#print dict
cur.close()
conn.close()

 

你可能感兴趣的:(oracle)