Asyncpg (asyncio/asyncpg.py, line 62, in get_query) get_query throws index error.
slice-ArpitSharma opened this issue · 0 comments
- asyncpg version:.29.0
- PostgreSQL version: 2.0.26
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: no - Python version: 3.8.12
- Platform: macos | arm | m1
- Do you use pgbouncer?: no
- Did you install asyncpg with pip?: yes
- If you built asyncpg locally, which version of Cython did you use?: na
- Can the issue be reproduced under both asyncio and
uvloop?: na
When executing my statements I get the indexError: tuple index out of range
This is the traceback i get:
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/session.py",
line 452, in execute
result = await greenlet_spawn(
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py",
line 197, in greenlet_spawn
result = context.throw(*sys.exc_info())
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py",
line 2306, in execute
return self._execute_internal(
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py",
line 2181, in _execute_internal
conn = self._connection_for_bind(bind)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py",
line 2050, in _connection_for_bind
return trans._connection_for_bind(engine, execution_options)
File "",
line 2, in _connection_for_bind
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/state_changes.py",
line 139, in _go
ret_value = fn(self, *arg, **kw)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py",
line 1144, in _connection_for_bind
conn = bind.connect()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py",
line 3258, in connect
return self._connection_cls(self)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py",
line 145, in init
self._dbapi_connection = engine.raw_connection()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/base.py",
line 3282, in raw_connection
return self.pool.connect()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py",
line 449, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py",
line 1263, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py",
line 712, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/impl.py",
line 169, in _do_get
self._dec_overflow()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py",
line 146, in exit
raise exc_value.with_traceback(exc_tb)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/impl.py",
line 166, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py",
line 390, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py",
line 674, in init
self.__connect()
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/pool/base.py",
line 912, in __connect
pool.dispatch.connect.for_modify(
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/event/attr.py",
line 489, in exec_w_sync_on_first_run
self(*args, **kw)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/event/attr.py",
line 497, in call
fn(*args, **kw)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/create.py",
line 710, in on_connect
do_on_connect(dbapi_connection)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py",
line 1244, in connect
conn.await(self.setup_asyncpg_json_codec(conn))
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py",
line 127, in await_only
return current.driver.switch(awaitable) # type: ignore[no-any-return]
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py",
line 192, in greenlet_spawn
value = await result
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py",
line 1170, in setup_asyncpg_json_codec
await asyncpg_connection.set_type_codec(
File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py",
line 1339, in set_type_codec
typeinfo = await self._introspect_type(typename, schema)
File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py",
line 543, in _introspect_type
rows = await self._execute(
File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py",
line 1794, in _execute
result, _ = await self.__execute(
File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py",
line 1892, in __execute
result, stmt = await self._do_execute(
File "/usr/local/lib/python3.8/site-packages/asyncpg/connection.py",
line 1945, in _do_execute
result = await executor(stmt, None)
File "/usr/local/lib/python3.8/site-packages/elasticapm/instrumentation/packages/asyncio/asyncpg.py",
line 65, in call
query = self.get_query(method, args)
File "/usr/local/lib/python3.8/site-packages/elasticapm/instrumentation/packages/asyncio/asyncpg.py",
line 62, in get_query
return args[0].queryIndexError: tuple index out of range
the orm model looks like this :
class Table(Base):
__tablename__ = "table"
id: Mapped[int] = mapped_column(primary_key=True)
uuid : Mapped[str] = mapped_column(String(256),index=True)
created_at : Mapped[datetime.datetime]
type: Mapped[str] = mapped_column(String(256))
reference_number : Mapped[str] = mapped_column(String(256))
book : Mapped[str] = mapped_column(String(256))
the statements i execute are as follows:
insert_stmt = insert(Table).values(data)
await session.execute(insert_stmt)
await session.commit()
return True