我制作了一个具有以下功能的搜索按钮:
def search(self):
conn=mysql.connector.connect(host="localhost",username="root",password="krish@123",database="face_monitoring")
mycursor=conn.cursor()
mycursor.execute("select * from room where"+str(self.search_var.get())+" LIKE '%"+str(self.txt_search.get())+"%'")
rows=mycursor.fetchall()
if len(rows)!=0:
self.room_details.delete(*self.room_details.get_children())
for i in rows:
self.room_details.insert("",END,values=i)
conn.commit()
conn.close()
错误:
mysql.connector.errors.programmingerror:1064(42000):您的SQL语法中有一个错误;检查与您的MySQL Server版本相对应的手册,以获取正确的语法
def search(self):
conn=mysql.connector.connect(host="localhost",username="root",password="krish@123",database="face_monitoring")
mycursor=conn.cursor()
mycursor.execute("select * from room where"+str(self.search_var.get())+" LIKE '%"+str(self.txt_search.get())+"%'")
rows=mycursor.fetchall()
if len(rows)!=0:
self.room_details.delete(*self.room_details.get_children())
for i in rows:
self.room_details.insert("",END,values=i)
conn.commit()
conn.close()
error:
mysql.connector.errors.ProgrammingError: 1064 (42000): 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 'Name LIKE '%krishna mishra%'' at line 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论