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

报错背景:

报错前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) value ("+"‘"+ List[0] + "‘" + ","+"‘"+ List[1]+ "‘"+")"
sql = "insert into para_ps(AcquisitionType, DataType, DeadbandType, EngUnit, MaxEU, MaxRaw, MinEU, MinRaw, RateDeadband, StorageRate, StorageType, TagDesc, TagKey, TagName, TagType, TimeStampp, Valuee, ValueDeadband) "                       "values("                      + "‘" + List[0] + "‘" + ","                       + "‘" + List[1] + "‘" + ","                       + "‘" + List[2] + "‘" + ","                       + "‘" + List[3] + "‘" + ","                       + "‘" + List[4] + "‘" + ","                       + "‘" + List[5] + "‘" + ","                       + "‘" + List[6] + "‘" + ","                       + "‘" + List[7] + "‘" + ","                       + "‘" + List[8] + "‘" + ","                       + "‘" + List[9] + "‘" + ","                       + "‘" + List[10] + "‘" + ","                       + "‘" + List[11] + "‘" + ","                       + "‘" + List[12] + "‘" + ","                       + "‘" + List[13] + "‘" + ","                       + "‘" + List[14] + "‘" + ","                       + "‘" + List[15] + "‘" + ","                       + "‘" + List[16] + "‘" + ","                       + "‘" + List[17] + "‘" +")"

主要功能是将python列表中的数据插入到Mysql数据库中的表中

sql表设计展示:

报错现象:

D:\Softwares\Python\python.exe "D:\Softwares\Pycharm\PyCharm 2019.1.2\helpers\pydev\pydevconsole.py" --mode=client --port=60400
import sys; print(‘Python %s on %s‘ % (sys.version, sys.platform))
sys.path.extend([‘D:\\Softwares\\Pycharm\\yk‘, ‘D:/Softwares/Pycharm/yk‘])
PyDev console: starting.
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
runfile(‘D:/Softwares/Pycharm/yk/bigdata/test/toSql2.py‘, wdir=‘D:/Softwares/Pycharm/yk/bigdata/test‘)
insert into para_ps(AType, DataType, DeadbandType, EngUnit, MaxEU, MaxRaw, MinEU, MinRaw, RateDeadband, StorageRate, StorageType, TagDesc, TagKey, TagName, TagType, TimeStampp, Valuee, ValueDeadband) values(‘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‘)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "D:\Softwares\Pycharm\PyCharm 2019.1.2\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "D:\Softwares\Pycharm\PyCharm 2019.1.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, ‘exec‘), glob, loc)
  File "D:/Softwares/Pycharm/yk/bigdata/test/toSql2.py", line 42, in <module>
    cur.execute(sql)
  File "D:\Softwares\Python\lib\site-packages\pymysql\cursors.py", line 170, in execute
    result = self._query(query)
  File "D:\Softwares\Python\lib\site-packages\pymysql\cursors.py", line 328, in _query
    conn.query(q)
  File "D:\Softwares\Python\lib\site-packages\pymysql\connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "D:\Softwares\Python\lib\site-packages\pymysql\connections.py", line 732, in _read_query_result
    result.read()
  File "D:\Softwares\Python\lib\site-packages\pymysql\connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "D:\Softwares\Python\lib\site-packages\pymysql\connections.py", line 684, in _read_packet
    packet.check_error()
  File "D:\Softwares\Python\lib\site-packages\pymysql\protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "D:\Softwares\Python\lib\site-packages\pymysql\err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1054, "Unknown column ‘AType‘ in ‘field list‘")

报错原因:

sql字段大小写问题!!!

报错解决:

全改成大写或者全改成小写,或者修改数据库设置。

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

原文地址:https://www.cnblogs.com/chuijingjing/p/11016653.html

时间: 2024-08-13 16:20:16

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

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

错误提示: 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",

报错pymysql.err.DataError: (1406, &quot;Data too long for column &#39;gender&#39; at row 1&quot;)

在Django默认的admin后台创建超级用户时, 报错pymysql.err.DataError: (1406, "Data too long for column 'gender' at row 1")的解决方法. 创建过程为: 点击tool菜单的run manage.py task,输入createsuperuser,运行,按提示输入用户名,邮件,密码,以及密码确认. 解决方法为: 在pycharm中按快捷键ctr+h,查找到gender的相应字段,如图: 我们可以看到设置的ge

MySQL数据库报错pymysql.err.InterfaceError: (0, &#39;&#39;)

今天入库的时候出现了报错pymysql.err.InterfaceError: (0, ''),经过排查,发现是由于把连接数据库的代码放到了插入函数的外部,导致多线程运行出错 1 def write_into_db(data): 2 db = pymysql.connect(host=db_host, user=db_user, password=db_password, port=db_port, db=db_name, charset='utf8') 3 cursor = db.cursor

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

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

错误代码: 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,

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

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