oracle_to_excel

# Export Oracle database tables to CSV files
# FB36 - 201007117
import sys
import csv
import cx_Oracle
connection ="dcm/Dcm_CbPc2@215.8.7.57:11521/dcsdb"
orcl = cx_Oracle.connect(connection)
curs = orcl.cursor()
printHeader = True # include column headers in each table output
tableName = 'DCS_RESERVED_data_CRSCB'
csv_file_dest = tableName + ".csv"
outputFile = open(csv_file_dest,'w') # 'wb'
output = csv.writer(outputFile, dialect='excel', lineterminator='\n')
sql = "select * from  DCS_RESERVED_data_CRSCB a "
curs2 = orcl.cursor()
curs2.execute(sql)
res = curs2.fetchall()
print(res)
cols = []
for col in curs2.description:
    cols.append(col[0])
    print(col[0])
output.writerow(cols)
output.writerows(res)
outputFile.close()

  

上一篇:OracleDBConsoleorcl启动失败_解决方法


下一篇:lvm合并调整分区大小