iT邦幫忙

0

這個問題出在哪? MYSQL連動pythom

  • 分享至 

  • xImage

import numpy
import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator
from pandas import read_csv
import math
from keras.models import Sequential
from keras.layers import Dense
#from keras.layers import LSTM
from keras.layers import LSTM

from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error
import tensorflow as tf

import mysql.connector
import pymysql
import datetime
from datetime import datetime

def create_dataset(dataset, look_back=1):
dataX, dataY = [], []
for i in range(len(dataset)-look_back-1):
a = dataset[i:(i+look_back), 0]
dataX.append(a)
dataY.append(dataset[i + look_back, 0])
return numpy.array(dataX), numpy.array(dataY)
numpy.random.seed(7)
config = {
'user': 'root',
'password': '',
'host': 'localhost',
#'database': 'raspberrydb',
#'database': 'power_mysql,
'database':"pm",
#'raise_on_warnings': True,
}
cnx = pymysql.connect(**config)
cursor = cnx.cursor()
cursor.execute("SELECT * FROM pm_blockchain_data")
results = cursor.fetchall()

我這樣打哪之前都可以,但不知道現在為什麼有問題了
是MYSQL設定跑掉?
現在MYSQL無法連結我的資料庫
Traceback (most recent call last):
File "C:\TSVSELE_William\Python_code\110_1_27\LSTM_PM_2020_01_11_u4_e50.py", line 49, in
cursor.execute("SELECT * FROM pm_blockchain_data")

ccutmis iT邦高手 2 級 ‧ 2021-01-30 16:30:36 檢舉
https://www.a2hosting.com/kb/developer-corner/mysql/connect-to-mysql-from-the-command-line
先確認Mysql有在運作 db:'pm' 存在 且可以用終端機命令登入作查詢 例如
use pm;
SELECT * FROM pm_blockchain_data;
這些都正常了 再來說 Python報什麼錯...
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答