关于pymysql问题


sql = f"insert into user(secret_key,user_name,email_address,user_group) values({z},{name},{E_mial},0)"
# 执行
cursor.execute(sql)
# 提交
conn.commit()

以上代码报错

C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\python.exe F:/编程项目(python)/数据库/用户程序/注册.py
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 1702, in __call__
    return self.func(*args)
  File "F:/编程项目(python)/数据库/用户程序/注册.py", line 58, in temp2
    cursor.execute(sql)
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\cursors.py", line 148, in execute
    result = self._query(query)
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\cursors.py", line 310, in _query
    conn.query(q)
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 548, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 775, in _read_query_result
    result.read()
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 1156, in read
    first_packet = self.connection._read_packet()
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "C:\Users\yuyeze\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
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 '@126.com,)

进程已结束,退出代码0


但是在数据库中运行:

insert into user(secret_key,user_name,email_address,user_group) values("1","1","1",0)

提示sql命令已执行
表结构:

img

emmm,你打印一下你的sql 字符串看看呢,是不是拼接错误了