'생산성 향상/Python'에 해당되는 글 2건

  1. 2017.07.13 [Python]how to make Dictionary List with cx_Oracle
  2. 2017.07.07 [Python]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
생산성 향상/Python2017. 7. 7. 09:45

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import cx_Oracle
 
con = cx_Oracle.connect('아이디/암호@아이피:1521/인스턴스명')
 
cur = con.cursor()
 
cur.execute('Query문')
 
for result in cur:
 
  print(result)
 
cur.close()
 
con.close()
 
cs

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
--모든 테이블 조회
SELECT *
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'


--컬럼 목록 조회
SELECT *
FROM COLS
WHERE TABLE_NAME = '테이블명'


SELECT *  FROM T_LOGIN_LOG
SELECT *  FROM COLS where TABLE_NAME = 'T_LOGIN_LOG'
SELECT *  FROM ALL_OBJECTS where OBJECT_TYPE = 'TABLE'

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

[Python]how to make Dictionary List with cx_Oracle  (0) 2017.07.13
Posted by JMPESP