所以我正在使用 aiohttp 和 asyncpg 开发 REST API。这是我对处理程序的基本看法:
from aiohttp.web_urldispatcher import View
from asyncpgsa import PG
class BaseView(View):
    URL_PATH: str
    @property
    def pg(self) -> PG:
        return self.request.app['pg']
我正在尝试对我的一个表进行选择查询并获取行:
query = select([regions_table.c.region_id]).select_from(regions_table)
regions = await self.pg.fetch(query)
但是,我从标题中得到错误:
File "blahblahblah/env/lib/python3.8/site-packages/asyncpg/connection.py", line 583, in fetch
    return await self._execute(
TypeError: _execute() got an unexpected keyword argument 'record_class'
我的猜测是,当调用没有参数的 execute() 时,fetch 和 fetchrow 有一个参数“record_class”。这是 fetch() 实现:
    async def fetch(
        self,
        query,
        *args,
        timeout=None,
        record_class=None
    ) -> list:
        
        self._check_open()
        return await self._execute(
            query,
            args,
            0,
            timeout,
            record_class=record_class,
        )
这里是_execute():
    def _execute(self, query, args, limit, timeout, return_status=False):
        query, compiled_args = compile_query(query, dialect=self._dialect)
        args = compiled_args or args
        return super()._execute(query, args, limit, timeout,
                                return_status=return_status)
但是我没有看到任何相关的问题,并且来自另一个项目的代码在相同的查询中运行良好。也许我错过了有关文档或处理这些库的内容?欢迎任何建议。