为什么会出现MySQL和Peewee Traceback错误

问题描述

我正在尝试从MysqL数据库提取数据并将其收集为字符串。我决定只从数据库中的每一行开始打印,但是我不断收到下面的错误。有什么想法吗?

Traceback (most recent call last):
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/peewee.py",line 3099,in execute_sql
    cursor.execute(sql,params or ())
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/cursors.py",line 163,in execute
    result = self._query(query)
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/cursors.py",line 321,in _query
    conn.query(q)
  ...
During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  ...

    raise value.with_traceback(tb)
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/peewee.py",in _query
    conn.query(q)
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/connections.py",line 505,in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/connections.py",line 724,in _read_query_result
    result.read()
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/connections.py",line 1069,in read
    first_packet = self.connection._read_packet()
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/connections.py",line 676,in _read_packet
    packet.raise_for_error()
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/protocol.py",line 223,in raise_for_error
    err.raise_MysqL_exception(self._data)
  File "/Users/lukebouch/GoogleDrive/My Drive/Development/Projects/20200815-BiblicalResponses/.venv/lib/python3.8/site-packages/pyMysqL/err.py",line 107,in raise_MysqL_exception
    raise errorclass(errno,errval)
peewee.OperationalError: (1054,"UnkNown column 't1.id' in 'field list'")

这是我的代码。出于明显的原因,我删除数据库凭据。

import MysqL.connector
from peewee import *

db = MysqLDatabase(host="########",user="########",password="########",database="lukesmed_biblical")

print(db)

class Response(Model):
  PRIMARY = IntegerField()
  category = TextField()
  text = TextField()
  class Meta():
    database = db
    table_name = "responses"


db.connect()
for text in Response.select():
  print(text().text)
db.close()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)