python tkinter 你的 SQL 语法有误

python tkinter You have an error in your SQL syntax

有人可以帮忙吗?

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\huzey\AppData\Local\Programs\Python\Python39\lib\site-packages\mysql\connector\connection_cext.py", line 506, in cmd_query
_mysql_connector.MySQLInterfaceError: 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 ')' at line 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\huzey\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "c:\Users\huzey\OneDrive\Masaüstü\gui\loginsystem.py", line 198, in add_customer
    my_cursor.execute(sql_command, values)
  File "C:\Users\huzey\AppData\Local\Programs\Python\Python39\lib\site-packages\mysql\connector\cursor_cext.py", line 269, in execute
    result = self._cnx.cmd_query(stmt, raw=self._raw,
  File "C:\Users\huzey\AppData\Local\Programs\Python\Python39\lib\site-packages\mysql\connector\connection_cext.py", line 510, in cmd_query
    raise errors.get_mysql_exception(exc.errno, msg=exc.msg,
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 ')' at line 1

这是完整的错误,这是代码中有错误的部分:

def add_customer():
    sql_command = "INSERT INTO customers (first_name, last_name, addres, phone, email, age, country, rent) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, )"
    values = (first_name_box.get(), last_name_box.get(), address_box.get(), phone_box.get(), email_box.get(), age_box.get(), country_box.get(), rent_box.get())
    my_cursor.execute(sql_command, values)
    mydb.commit()
    clear_all()

顺便说一句,我正在尝试制作一个房地产管理系统。如果您有任何想法,我愿意接受新想法和代码,如果您愿意,我可以提供详细信息。

你最后多了一个逗号:

... VALUES (%s, %s, %s, %s, %s, %s, %s, %s, )

摆脱它——当你这样做时,你可以将语句拆分成多个文字以提高可读性:

sql_command = (
    "INSERT INTO customers "
    "(first_name, last_name, addres, phone, email, age, country, rent) "
    "VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
)