錯誤訊息
pymysql.err.ProgrammingError:
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Beitun_District'' at line 1")
app檔
def Select():
if request.method == 'GET':
session.clear()
form = m.SelectForm()
return render_template('index.html', form=form)
else:
form = m.SelectForm(request.form)
if request.method =='POST' and form.validate():
add = request.form['add']
agg = request.form['agg']
detail= m.sql_read(add)
module檔
def sql_read(add):
connection = pymysql.connect(host='********',
port=3307,
user='root',
password='*****',
database='taichung',
charset='utf8mb4')
with connection:
with connection.cursor() as cursor:
sql = "SELECT * FROM %s "
cursor.execute(sql,add)
rows=cursor.fetchall()
connection.commit()