, 내가 thefollowing 기능 CSV에 데이터베이스에서 추출 열 이름의 cx_Oracle과 인쇄 변수 금액 :파이썬 - 주어진 SQL 문을 기반으로
def extract_from_db():
with open('myfile.csv','w') as outfile:
for row in cursor:
outfile.write(str(row[0])+";"+str(row[1])+";"+str(row[2])+";"+str(row[3])+";"+str(row[4])+";"+str(row[5])
+";"+str(row[6])+";"+str(row[7])+";"+str(row[8])+";"+str(row[9])+";"+str(row[10])+";"+str(row[11])+";"+str(row[12])
+";"+str(row[13])+";"+str(row[14])+"\n")
가 어떻게 파일 칼럼의 시작 부분에 쓸 수 있습니다 열의 가변 양에 대한 이름, 그래서 그것을 하드 코드하지 않아도됩니까? 또한 하드 코드 된 연결은 꽤 추합니다.