keyerror при попытке вставить дату и время в Postgresql (pg8000) - PullRequest
0 голосов
/ 05 августа 2020

Я пытаюсь вставить datetime в pg sql с

f'UPDATE userdata SET claimed = {fclaim} WHERE userid = {user.id}'

вот как создается переменная fclaim

   nextclaim = datetime.datetime.now() + datetime.timedelta(hours=24)
   
   fclaim = nextclaim + datetime.timedelta(hours=24)

Когда я пытаюсь вставьте fclaim в postgresql, я получаю следующую ошибку:

  File "/home/server/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 83, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/server/Documents/blutonium/extensions/points.py", line 162, in daily
    isClaimed = blutapi.getclaimed(ctx.author)
  File "/home/server/Documents/blutonium/blutapi.py", line 445, in getclaimed
    db.run(sql)
  File "/home/server/.local/lib/python3.6/site-packages/pg8000/core.py", line 954, in run
    self._run_cursor.execute(sql, params, stream=stream)
  File "/home/server/.local/lib/python3.6/site-packages/pg8000/core.py", line 351, in execute
    self._c.execute_unnamed(self, operation, args)
  File "/home/server/.local/lib/python3.6/site-packages/pg8000/core.py", line 1262, in execute_unnamed
    args = make_args(vals)
  File "/home/server/.local/lib/python3.6/site-packages/pg8000/core.py", line 213, in make_args
    return tuple(vals[p] for p in placeholders)
  File "/home/server/.local/lib/python3.6/site-packages/pg8000/core.py", line 213, in <genexpr>
    return tuple(vals[p] for p in placeholders)
KeyError: '37' 

, используя python 3.6.11 на ubuntu 20.04

...