'Database'에 해당되는 글 1건

  1. 2017.07.13 [Python]how to make Dictionary List with cx_Oracle
생산성 향상/Python2017. 7. 13. 11:13

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import cx_Oracle
 
def makedict(cursor):
"""Convert cx_oracle query result to be a dictionary   
"""
cols = [d[0for d in cursor.description]
 
def createrow(*args):
    return dict(zip(cols, args))
 
return createrow
 
db = cx_Oracle.connect('user''pw''host')
cursor = db.cursor()
rs = cursor.execute('SELECT * FROM Tablename')
cursor.rowfactory = makedict(cursor)
cs
https://stackoverflow.com/questions/10455863/making-a-dictionary-list-with-cx-oracle

'생산성 향상 > Python' 카테고리의 다른 글

[Python]Oracle 접속  (0) 2017.07.07
Posted by JMPESP