上脚本
import cx_Oracle
import pandas as pd
import matplotlib.pyplot as plt
import datetime
import xlwt
import os
conn = cx_Oracle.connect('root/root@127.0.0.1:1521/orcl')
cursor = conn.cursor()
result = cursor.execute(r"select timestamp, F29 from table order by timestamp")
all_data = cursor.fetchall()
x = []
y = []
for i in range(1, len(all_data)):
line = all_data[i]
x.append(str(line[0]))
y.append(line[1])
print(x)
print(y)
workbook = xlwt.Workbook(encoding='utf-8')
data_sheet = workbook.add_sheet("show_data")
row = 0
col = 0
for row in range(0, len(x)):
data_sheet.write(row, 0, x[row])
data_sheet.write(row, 1, y[row])
xls_path = os.path.join("d:/", "Excel.xls")
workbook.save(xls_path)