Sqlalchemy使用数据集模块的未使用的列名称

时间:2016-10-08 11:05:30

标签: python sqlite python-3.x sqlalchemy

我目前正在开发一款游戏。此游戏将数据存储在sqlite数据库中。我正在使用dataset来管理数据库,所以我不必担心SQL查询。我有一个方法访问数据库以更新播放器信息:

def updatePlayerInfo(channel, info): # Context at https://github.com/DuckHunt-discord/DuckHunt-Discord/blob/master/database.py#L33
    table = getChannelTable(channel)
    table.upsert(info, ["id_"]) 
    # An UPSERT is a smart combination of insert and update.
    # If rows with matching keys exist they will be updated, otherwise a new row is inserted in the table.

此功能适用于几乎所有内容。只有一件事会产生错误:使用munAP_作为列名! (仅存储整数时间戳) 其他一些列的工作方式相同,但不受单个bug的影响! 引发的例外情况如下:

Ignoring exception in on_message
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/discord/client.py", line 245, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "./main.py", line 1022, in on_message
    if database.getStat(message.channel, message.author, "chargeurs",
  File "/home/cloudbot/discord-bot/database.py", line 45, in setStat
    updatePlayerInfo(channel, dict_)
  File "/home/cloudbot/discord-bot/database.py", line 35, in updatePlayerInfo
    table.upsert(info, ["id_"])
  File "/usr/local/lib/python3.4/dist-packages/dataset/persistence/table.py", line 185, in upsert
    row_count = self.update(row, keys, ensure=ensure, types=types)
  File "/usr/local/lib/python3.4/dist-packages/dataset/persistence/table.py", line 154, in update
    rp = self.database.executable.execute(stmt)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", line 1991, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/engine/base.py", line 1003, in _execute_clauseelement
    inline=len(distilled_params) > 1)
  File "<string>", line 1, in <lambda>
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/elements.py", line 494, in compile
    return self._compiler(dialect, bind=bind, **kw)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/elements.py", line 500, in _compiler
    return dialect.statement_compiler(dialect, self, **kw)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/compiler.py", line 395, in __init__
    Compiled.__init__(self, dialect, statement, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/compiler.py", line 190, in __init__
    self.string = self.process(self.statement, **compile_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/compiler.py", line 213, in process
    return obj._compiler_dispatch(self, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch
    return meth(self, **kw)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/compiler.py", line 1958, in visit_update
    crud_params = crud._get_crud_params(self, update_stmt, **kw)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/crud.py", line 109, in _get_crud_params
    (", ".join("%s" % c for c in check))
sqlalchemy.exc.CompileError: Unconsumed column names: munAP_

https://github.com/DuckHunt-discord/DuckHunt-Discord/issues/8

我已经尝试更改列名(之前是munAP),但它没有改变任何内容!

我还能尝试什么?我怀疑问题出在我的代码中,但也许是数据集故障?

0 个答案:

没有答案