pymysql.err.InternalError: (1054, "Unknown column 'None' in 'field list'")

错误提示:

Traceback (most recent call last):
  File "D:/projectwc/test/dd.py", line 43, in <module>
    effect_row = cursor.execute("insert into `222` set c={}".format(None))
  File "C:\python\lib\site-packages\pymysql\cursors.py", line 166, in execute
    result = self._query(query)
  File "C:\python\lib\site-packages\pymysql\cursors.py", line 322, in _query
    conn.query(q)
  File "C:\python\lib\site-packages\pymysql\connections.py", line 835, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "C:\python\lib\site-packages\pymysql\connections.py", line 1019, in _read_query_result
    result.read()
  File "C:\python\lib\site-packages\pymysql\connections.py", line 1302, in read
    first_packet = self.connection._read_packet()
  File "C:\python\lib\site-packages\pymysql\connections.py", line 981, in _read_packet
    packet.check_error()
  File "C:\python\lib\site-packages\pymysql\connections.py", line 393, in check_error
    err.raise_mysql_exception(self._data)
  File "C:\python\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1054, "Unknown column ‘None‘ in ‘field list‘")
import pymysql

# 创建连接
conn = pymysql.connect(host=‘192.168.72.135‘, port=3306, user=‘root‘, passwd=‘123456‘, db=‘test‘)
# 创建游标
cursor = conn.cursor()

# 执行SQL,并返回收影响行数
effect_row = cursor.execute("insert into `222` set c={}".format(None))

# 提交,不然无法保存新建或者修改的数据
conn.commit()

# 关闭游标
cursor.close()
# 关闭连接
conn.close()

解决办法:

把None 换成“Null”

effect_row = cursor.execute("insert into `222` set c={}".format("Null"))

pymysql.err.InternalError: (1054, "Unknown column 'None' in 'field list'")

时间: 2024-10-11 07:00:59

pymysql.err.InternalError: (1054, "Unknown column 'None' in 'field list'")的相关文章

报错:pymysql.err.InternalError: (1054, &quot;Unknown column &#39;AType&#39; in &#39;field list&#39;&quot;)

报错背景: 报错前sql代码展示: List = ['Manual', 'Float', 'TimeValue', 'None', '100', '100', '0', '0', '0', '0', 'Forced', '排水系统3#中央泵负压', '556', 'SLWS_ps_3hzybf_YL.PV', 'Analog', '2019/6/13 8:32:46', '-0.0034143477678299', '0'] # sql = "insert into test(id, name)

django 修改字段后,同步数据库,失败:django.db.utils.InternalError: (1054, &quot;Unknown column &#39;api_config.project_id_id&#39; in &#39;field list&#39;&quot;)

问题原因是,修改字段后,同步失败了,然后执行查询的时候,就会提示这个错误,这个字段没有 最暴力的方法可以直接在数据库中修改字段,但是修改后,models没同步,可能会存在问题,因此开始我的百度之旅(这个问题网上资料还真的挺少的) 方法一,不要犹豫,重启大法,关闭项目,关闭开发工具,从新打开,这个方法好像不行 方法二,删除大法,因为django有models在,数据库建表还是很容易的,只不过是数据丢失了,对我我这种不正经的开发来说,无关紧要咯 所以,我删除了库,删除了django生成的migrat

错误代码: 1054 Unknown column &#39;course&#39; in &#39;field list&#39;

1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT stu_name, course, score FROM t_student_info s LIMIT 0, 1000 错误代码: 1054 Unknown column 'course' in 'field list' 执行耗时 : 0 sec 传送时间 : 0 sec 总耗时 : 0 sec 2.错误原因 SELECT stu_name, course,

discuzX3.2错误 (1054) Unknown column &#39;conuintoken&#39; in &#39;field list&#39;

开启QQ互联后,点击登录以后报错:(1054) Unknown column 'conuintoken' in 'field list'   下面把解决方法分享一下: 输入以下句子运行:(其中的 pre_ 为你论坛数据库的表前缀,如果不是默认的,请注意修改) ALTER TABLE  `pre_common_member_connect` ADD COLUMN conuintoken char(32) NOT NULL DEFAULT '';ALTER TABLE  `pre_common_co

pymysql.err.InternalError: 1075

pymysql.err.InternalError: (1075, 'Incorrect table definition; there can be only one auto column and it must be defined as a key') python中使用pymysql创建table是报错是上面标题,sql语句如下:sql = '''create table music (id int not null auto_increment, song text,singer t

错误代码: 1054 Unknown column &#39;t.createUsrId&#39; in &#39;group statement&#39;

1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:select count(t.id),t.`createUserId` from t_acs_ints t where t.id not in (SELECT t1.ionId FROM t_acs_cont t1, t_ac... 错误代码: 1054 Unknown column 't.createUsrId' in 'group statement' 执行耗时 : 0

InternalError: (pymysql.err.InternalError) (1205, u&#39;Lock wait timeout exceeded; try restarting transaction&#39;)

在mysql innodb中使用事务,如果插入或者更新出错,一定要主动显式地执行rollback,否则可能产生不必要的锁而锁住其他的操作 我们在使用数据库的时候,可以使用contextlib,这样异常的时候自动回滚,而且最后都会执行关闭操作 from contextlib import contextmanager engine = create_engine(EREBUS_DB_CONNECT_STRING, echo=True, pool_size=150, max_overflow=50,

Error Code: 1054. Unknown column &#39;age&#39; in &#39;user&#39;

1.错误描述 10:28:20 alter table user modify age int(3) after sex Error Code: 1054. Unknown column 'age' in 'user' 0.000 sec 2.错误原因 原本在user表中有age字段,但是在测试阶段删除了,后期将age位置修改,所以报错 3.解决办法 首先,先向user表中插入age字段:然后再修改它的位置 Error Code: 1054. Unknown column 'age' in 'u

mysql命令 出现ERROR 1054 (42S22): Unknown column &#39;password&#39; in &#39;field list&#39;

1.安装 brew install msyql 2.更新 brew upgrade mysql 3.启动 To have launchd start mysql now and restart at login: brew services start mysqlOr, if you don't want/need a background service you can just run: mysql.server start 4.登录 mysql -uroot 5.查看用户及密码 selec