我这样通过python拍摄查询:
<div class="col-md-4">
<div class="card mb-5 light-blue">
<div class="amount"><h4>10 left</h4></div>
<img class="card-img-top" src="images/donation.jpg" alt="Donation">
<div class="card-body">
<h4>Donation 1</h4>
<p class="card-text">Donation description goes here</p>
<div class="d-flex justify-content-center align-items-center">
<button type="button" class="btn btn-sm btn-outline-secondary">Donate $50</button>
</div>
</div>
</div>
</div>
效果很好。但是,如果到了这一点,我将使用一个空格符,则会收到一条错误消息:/
cur.execute("INSERT INTO tblMQTTtest (string) VALUES ('test')")
con.commit()
错误:
var1 = 'mystring' cur.execute("INSERT INTO tblMQTTtest (string) VALUES (%s)", (var1)) con.commit()
有什么想法吗?
答案 0 :(得分:-1)
我认为您需要用%替换逗号。 Python不知道如何在没有%s
运算符的情况下填写%
。试试:
cur.execute("INSERT INTO tblMQTTtest (string) VALUES (%s)" % var1 )