“runtimeerror:无法检索mysql上的最后一个insert id”

hrysbysz  于 2021-06-15  发布在  Mysql
关注(0)|答案(2)|浏览(333)

我正在安装 Prelude Package 和 Prewikka 来自此源的包。我遵循本手册用户的所有说明。
我已经在我的ubuntu上构建了所有源代码,但是当我尝试连接到 localhost:8000 ,我从服务器端得到错误:

$ prewikka-httpd
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/bin/prewikka-httpd", line 62, in application
    return wsgi.application(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/web/wsgi.py", line 161, in application
    core.process(WSGIRequest(environ, start_response))
  File "/usr/local/lib/python2.7/dist-packages/prewikka/main.py", line 280, in process
    response = err.respond()
  File "/usr/local/lib/python2.7/dist-packages/prewikka/error.py", line 106, in respond
    return self._html_respond()
  File "/usr/local/lib/python2.7/dist-packages/prewikka/error.py", line 90, in _html_respond
    from prewikka import baseview
  File "/usr/local/lib/python2.7/dist-packages/prewikka/baseview.py", line 27, in <module>
    from prewikka import error, history, hookmanager, resource, response, template, utils, view
  File "/usr/local/lib/python2.7/dist-packages/prewikka/history.py", line 102, in <module>
    crontab.schedule("search_history", N_("Search history deletion"), "0 * * * *", _regfunc=history._history_cron, enabled=True)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 240, in schedule
    self._init_system_job(ext_type, name, schedule, enabled, _regfunc)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/database.py", line 91, in inner
    ret = func(self, *args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 152, in _init_system_job
    res = env.db.query("SELECT 1 FROM Prewikka_Crontab WHERE ext_type=%s AND userid IS NULL", ext_type)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/database.py", line 547, in query
    return preludedb.SQL.query(self, sql)
RuntimeError: Table 'prewikka.Prewikka_Crontab' doesn't exist

因此,我尝试手动创建一个表数据库,如:

mysql> desc Prewikka_Crontab;
+----------+-----------+------+-----+---------+-------+
| Field    | Type      | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------+-------+
| id       | int(11)   | YES  | UNI | NULL    |       |
| name     | char(255) | NO   | PRI | NONE    |       |
| userid   | int(11)   | YES  | UNI | NULL    |       |
| schedule | char(255) | NO   | UNI | NONE    |       |
| ext_type | char(255) | NO   | UNI | NONE    |       |
| ext_id   | int(11)   | YES  | UNI | NULL    |       |
| base     | char(255) | NO   | UNI | NONE    |       |
| runcnt   | char(255) | NO   | UNI | NONE    |       |
| enabled  | char(255) | NO   | UNI | NONE    |       |
| error    | char(255) | NO   | UNI | NONE    |       |
+----------+-----------+------+-----+---------+-------+
10 rows in set (0.09 sec)

mysql>

然后我尝试连接到 localhost:8000 同样,我得到了错误:

$ prewikka-httpd
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/bin/prewikka-httpd", line 62, in application
    return wsgi.application(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/web/wsgi.py", line 161, in application
    core.process(WSGIRequest(environ, start_response))
  File "/usr/local/lib/python2.7/dist-packages/prewikka/main.py", line 280, in process
    response = err.respond()
  File "/usr/local/lib/python2.7/dist-packages/prewikka/error.py", line 106, in respond
    return self._html_respond()
  File "/usr/local/lib/python2.7/dist-packages/prewikka/error.py", line 90, in _html_respond
    from prewikka import baseview
  File "/usr/local/lib/python2.7/dist-packages/prewikka/baseview.py", line 27, in <module>
    from prewikka import error, history, hookmanager, resource, response, template, utils, view
  File "/usr/local/lib/python2.7/dist-packages/prewikka/history.py", line 102, in <module>
    crontab.schedule("search_history", N_("Search history deletion"), "0 * * * *", _regfunc=history._history_cron, enabled=True)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 240, in schedule
    self._init_system_job(ext_type, name, schedule, enabled, _regfunc)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/database.py", line 91, in inner
    ret = func(self, *args,**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 154, in _init_system_job
    self.add(name, schedule, ext_type=ext_type, enabled=enabled)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 219, in add
    return self.update(None, name=name, schedule=schedule, user=user, ext_type=ext_type, ext_id=ext_id, enabled=enabled)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/crontab.py", line 209, in update
    return env.db.getLastInsertIdent()
RuntimeError: could not retrieve last insert ID

我还是不明白这些错误 RuntimeError: could not retrieve last insert ID 在我的数据库里。
编辑#1
我尝试了@vineesh建议,我的表数据库是:

mysql> DESC Prewikka_Crontab;
+----------+-----------+------+-----+---------+----------------+
| Field    | Type      | Null | Key | Default | Extra          |
+----------+-----------+------+-----+---------+----------------+
| id       | int(11)   | NO   | PRI | NULL    | auto_increment |
| name     | char(255) | NO   | UNI | NONE    |                |
| userid   | int(11)   | YES  | UNI | NULL    |                |
| schedule | char(255) | NO   | UNI | NONE    |                |
| ext_type | char(255) | NO   | UNI | NONE    |                |
| ext_id   | int(11)   | YES  | UNI | NULL    |                |
| base     | char(255) | NO   | UNI | NONE    |                |
| runcnt   | char(255) | NO   | UNI | NONE    |                |
| enabled  | char(255) | NO   | UNI | NONE    |                |
| error    | char(255) | NO   | UNI | NONE    |                |
+----------+-----------+------+-----+---------+----------------+
10 rows in set (0.03 sec)

当我连接服务器时,会出现以下错误:

$ prewikka-httpd
Traceback (most recent call last):
  File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/local/bin/prewikka-httpd", line 62, in application
    return wsgi.application(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/web/wsgi.py", line 161, in application
    core.process(WSGIRequest(environ, start_response))
  File "/usr/local/lib/python2.7/dist-packages/prewikka/main.py", line 280, in process
    response = err.respond()
  File "/usr/local/lib/python2.7/dist-packages/prewikka/error.py", line 106, in respond
    return self._html_respond()
  File "/usr/local/lib/python2.7/dist-packages/prewikka/error.py", line 91, in _html_respond
    return baseview.BaseView().respond(self._setup_template(self.template, False), self.code)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/view.py", line 481, in __init__
    registrar.DelayedRegistrar.__init__(self)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/registrar.py", line 46, in __init__
    i(ref)
  File "/usr/local/lib/python2.7/dist-packages/prewikka/view.py", line 583, in _add_route
    self._views_rules[rule] = v
TypeError: unhashable type: 'Rule'

我该怎么办?希望有人能帮我!
提前谢谢。

djmepvbi

djmepvbi1#

输出错误出现的原因是我的索引表上的表非常糟糕。我需要删除它并重新创建它。
python脚本上的format表
所需表格:

mysql> DESC Prewikka_Crontab;
+----------+---------------------+------+-----+---------+----------------+
| Field    | Type                | Null | Key | Default | Extra          |
+----------+---------------------+------+-----+---------+----------------+
| id       | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| name     | varchar(255)        | NO   |     | NULL    |                |
| userid   | varchar(32)         | YES  |     | NULL    |                |
| schedule | varchar(32)         | YES  |     | NULL    |                |
| ext_type | varchar(255)        | YES  |     | NULL    |                |
| ext_id   | int(11)             | YES  |     | NULL    |                |
| base     | datetime            | NO   |     | NULL    |                |
| enabled  | tinyint(4)          | YES  |     | 1       |                |
| runcnt   | int(11)             | YES  |     | 0       |                |
| error    | text                | YES  |     | NULL    |                |
+----------+---------------------+------+-----+---------+----------------+
10 rows in set (0.01 sec)

希望这有帮助。

mf98qq94

mf98qq942#

表“prewikka\u crontab”中的id字段应该是一个自动递增列。

相关问题