如何在Web2py中求解重复的列名错误

发布于 2025-02-10 12:11:26 字数 4079 浏览 3 评论 0原文

我正在pythonanywhere上运行web2py。 DB.PY文件运行时,我已经开始获得重复的列名错误。我已经尝试从备份恢复数据库,还将表放回桌子并将其添加回去,而无需成功。在这一点上,我完全被锁定在我的应用程序之外。

我尝试删除表中的所有最后一个字段,但随后出现了下一个表中的问题。

我想知道Web2py是否使用需要清除的缓存。

这是我的db.py文件的相关部分:

db.define_table('library',
            Field('title', 'string'),
            Field('created','datetime'),
            Field('duration','float'),
            Field('error_message','string'),
            Field('external_id','string'),
            Field('hosting_type','string'),
            Field('source_id','string', unique = True),
            Field('last_modified','datetime'),
            Field('media_type','string'),
            Field('mime_type','string'),
            Field('relationships','string'),
            Field('source_schema','string'),
            Field('source_url','string'),
            Field('status','string'),
            Field('trim_in_point','string'),
            Field('trim_out_point','string'),
            Field('source_type','string'),
            Field('poster','string'),
            Field('background_poster_filename','string'),
            Field('background_poster','upload', required=False, requires = IS_EMPTY_OR(IS_IMAGE(extensions=('png', 'jpg', 'jpeg'), maxsize=(1920, 1080)))),
            Field('sources','list:string',length = 4096),
            Field('tracks','string'),
            singular="Library",
            plural="Library"
           )

这是错误票:

Ticket ID
67.0.14.100.2022-06-23.16-49-09.ecf75fd3-1bb4-4f76-b557-95e072c6681f

<class 'gluon.contrib.pymysql.err.InternalError'> (1060, "Duplicate column name 'title'")
Version
web2py™ Version 2.21.1-stable+timestamp.2020.11.28.04.10.44
Python  Python 3.7.10: /usr/local/bin/uwsgi (prefix: /home/ghdev/.virtualenvs/ghdevvirtualenv)
Traceback
Traceback (most recent call last):
  File "/home/ghdev/web2py/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
  File "/home/ghdev/web2py/applications/ghrokucms/models/db.py", line 283, in <module>
plural="Library"
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/base.py", line 660, in define_table
table = self.lazy_define_table(tablename, *fields, **kwargs)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/base.py", line 701, in lazy_define_table
polymodel=polymodel,
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/adapters/base.py", line 920, in create_table
return self.migrator.create_table(*args, **kwargs)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/migrator.py", line 376, in create_table
fake_migrate=fake_migrate,
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/migrator.py", line 544, in migrate_table
self.adapter.execute(sub_query)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 69, in wrap
return f(*args, **kwargs)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/adapters/base.py", line 468, in execute
rv = self.cursor.execute(command, *args[1:], **kwargs)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/cursors.py", line 166, in execute
result = self._query(query)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/cursors.py", line 322, in _query
conn.query(q)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 835, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 1019, in _read_query_result
result.read()
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 1302, in read
first_packet = self.connection._read_packet()
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 981, in _read_packet
packet.check_error()
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
gluon.contrib.pymysql.err.InternalError: (1060, "Duplicate column name 'title'")

我不知所措,无法弄清楚如何解决此问题。任何帮助将不胜感激。

谢谢。

I'm running web2py on pythonanywhere. I've started getting a duplicate column name error when the db.py file runs. I've tried restoring the database from a backup and also dropping the table and adding it back, without success. At this point I'm completely locked out of my app.

I've tried removing all but the last field in the table, but then the problem appears in the next table.

I'm wondering if web2py uses a cache that needs to be cleared.

Here is the relevant portion of my db.py file:

db.define_table('library',
            Field('title', 'string'),
            Field('created','datetime'),
            Field('duration','float'),
            Field('error_message','string'),
            Field('external_id','string'),
            Field('hosting_type','string'),
            Field('source_id','string', unique = True),
            Field('last_modified','datetime'),
            Field('media_type','string'),
            Field('mime_type','string'),
            Field('relationships','string'),
            Field('source_schema','string'),
            Field('source_url','string'),
            Field('status','string'),
            Field('trim_in_point','string'),
            Field('trim_out_point','string'),
            Field('source_type','string'),
            Field('poster','string'),
            Field('background_poster_filename','string'),
            Field('background_poster','upload', required=False, requires = IS_EMPTY_OR(IS_IMAGE(extensions=('png', 'jpg', 'jpeg'), maxsize=(1920, 1080)))),
            Field('sources','list:string',length = 4096),
            Field('tracks','string'),
            singular="Library",
            plural="Library"
           )

Here is the error ticket:

Ticket ID
67.0.14.100.2022-06-23.16-49-09.ecf75fd3-1bb4-4f76-b557-95e072c6681f

<class 'gluon.contrib.pymysql.err.InternalError'> (1060, "Duplicate column name 'title'")
Version
web2py™ Version 2.21.1-stable+timestamp.2020.11.28.04.10.44
Python  Python 3.7.10: /usr/local/bin/uwsgi (prefix: /home/ghdev/.virtualenvs/ghdevvirtualenv)
Traceback
Traceback (most recent call last):
  File "/home/ghdev/web2py/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
  File "/home/ghdev/web2py/applications/ghrokucms/models/db.py", line 283, in <module>
plural="Library"
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/base.py", line 660, in define_table
table = self.lazy_define_table(tablename, *fields, **kwargs)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/base.py", line 701, in lazy_define_table
polymodel=polymodel,
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/adapters/base.py", line 920, in create_table
return self.migrator.create_table(*args, **kwargs)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/migrator.py", line 376, in create_table
fake_migrate=fake_migrate,
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/migrator.py", line 544, in migrate_table
self.adapter.execute(sub_query)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 69, in wrap
return f(*args, **kwargs)
  File "/home/ghdev/web2py/gluon/packages/dal/pydal/adapters/base.py", line 468, in execute
rv = self.cursor.execute(command, *args[1:], **kwargs)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/cursors.py", line 166, in execute
result = self._query(query)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/cursors.py", line 322, in _query
conn.query(q)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 835, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 1019, in _read_query_result
result.read()
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 1302, in read
first_packet = self.connection._read_packet()
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 981, in _read_packet
packet.check_error()
  File "/home/ghdev/web2py/gluon/contrib/pymysql/connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
  File "/home/ghdev/web2py/gluon/contrib/pymysql/err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
gluon.contrib.pymysql.err.InternalError: (1060, "Duplicate column name 'title'")

I'm at a loss to figure how to resolve this. Any help would be greatly appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

临风闻羌笛 2025-02-17 12:11:26

我解决了这个问题。除了丢弃表外,我还需要在Web2PY数据库目录中删除关联的文件。然后,我不得不手动将表格添加到MySQL数据库中。

已解决。

I solved this problem. In addition to dropping the table, I needed to delete the associated file in the web2py database directory. I then had to manually add back the table to the mySql database.

SOLVED.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文