【发布时间】:2021-10-14 22:38:17
【问题描述】:
我正在尝试执行此代码:
result = await conn.executemany(command=query, args=records)
查询在哪里:
INSERT INTO elexeon_time_series (subject, flow, timestamp, value, update_time, environment) VALUES ($1, $2, $3, $4, $5, $6);
记录由以下数据组成:
[{'environment': 'test',
'flow': 'test_flow',
'subject': 'test_subject_K4oESG2YRrnUhld',
'timestamp': Timestamp('2021-08-11 10:34:19.458810'),
'update_time': Timestamp('2021-08-11 12:34:19.458810'),
'value': 0.4},
{'environment': 'test',
'flow': 'test_flow',
'subject': 'test_subject_K4oESG2YRrnUhld',
'timestamp': Timestamp('2021-08-11 11:34:19.458810'),
'update_time': Timestamp('2021-08-11 12:34:19.458810'),
'value': 0.5}]
当我尝试执行这段代码时,我得到了一个相当神秘的回溯。任何人都可以解释这意味着什么?我做错了什么?
test_postgres_aio.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\eunrg_utils\database\postgres_async.py:33: in async_insert_postgres_data
result = await conn.executemany(command=query, args=records)
C:\installs\anaconda\envs\eunrg_utils\lib\site-packages\asyncpg\connection.py:355: in executemany
return await self._executemany(command, args, timeout)
C:\installs\anaconda\envs\eunrg_utils\lib\site-packages\asyncpg\connection.py:1677: in _executemany
result, _ = await self._do_execute(query, executor, timeout)
C:\installs\anaconda\envs\eunrg_utils\lib\site-packages\asyncpg\connection.py:1711: in _do_execute
result = await executor(stmt, None)
asyncpg\protocol\protocol.pyx:254: in bind_execute_many
???
asyncpg\protocol\coreproto.pyx:945: in asyncpg.protocol.protocol.CoreProtocol._bind_execute_many_more
???
asyncpg\protocol\protocol.pyx:220: in genexpr
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> ???
E KeyError: 0
asyncpg\protocol\prepared_stmt.pyx:149: KeyError
【问题讨论】:
标签: python python-asyncio asyncpg