我制作了一个具有以下功能的搜索按钮:

发布于 2025-02-07 04:02:29 字数 658 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文