资源简介
实时负荷预测,15分钟到4小时
代码片段和文件信息
import MySQLdb
import pandas as pd
class Data():
def connect(self):
self.db = MySQLdb.Connect(“192.168.0.250“ “mywind“ “123456“ “pems“)
self.cursor = self.db.cursor()
# print(“连接数据库成功“)
def getModelData(self):
self.connect()
self.cursor.execute(
“SELECT time volum FROM data_load“)
data = self.cursor.fetchall()
self.db.close()
data = self.prefixData(data)
return data
def getPredictData(self startTime endTime):
self.connect()
sql = “SELECT time volum FROM data_load where time between ‘“ + startTime + “‘ and ‘“ + endTime + “‘“
self.cursor.execute(sql)
data = self.cursor.fetchall()
self.db.close()
data = self.prefixData(data)
return data
def savePredictData(self time value):
# self.connect()
sql = ‘‘
id = self.countTime(time)
if self.countTime(time) > 0:
sql = “UPDATE data_load set predict = “ + str(value) + “ where id=“ + str(id)
else:
sql = “INSERT INTO data_load(time predict) VALUES (‘“ + time + “‘“ + str(value) + “)“
print(sql)
self.cursor.execute(sql)
self.db.commit()
self.db.close()
# sql = “““ insert into %s %s values %s “““ % (dbName dbField data_values)
def countTime(self time):
self.connect()
sql = “SELECT id FROM pems.data_load where time = ‘“ + time + “‘“
self.cursor.execute(sql)
data = self.cursor.fetchone()[0]
print(data)
return data
def prefixData(self data):
ret = [];
for i in range(len(data)):
ret.append(data[i][1])
return ret;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 36963 2020-11-23 14:41 数据集\data_load.csv
文件 144919 2019-08-14 22:43 数据集\loaddata.txt
文件 1844 2020-09-02 17:41 源码\data.py
文件 3777 2020-09-02 17:41 源码\LSTM.py
文件 2413 2020-09-02 17:41 源码\predict.py
目录 0 2020-11-23 14:46 数据集
目录 0 2020-11-23 14:46 源码
----------- --------- ---------- ----- ----
189916 7
- 上一篇:超级玛丽 python源码
- 下一篇:QPA进程抓包工具
评论
共有 条评论