fastapi-amis-admin icon indicating copy to clipboard operation
fastapi-amis-admin copied to clipboard

使用postgresql asyncpg 时报错

Open yxlwfds opened this issue 11 months ago • 0 comments

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 371, in run_asgi result = await app(self.scope, self.receive, self.send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 59, in call return await self.app(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/applications.py", line 271, in call await super().call(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/applications.py", line 118, in call await self.middleware_stack(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in call raise exc File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in call await self.app(scope, receive, _send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/base.py", line 109, in call await response(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/responses.py", line 277, in call await wrap(partial(self.listen_for_disconnect, receive)) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 662, in aexit raise exceptions[0] File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/responses.py", line 273, in wrap await func() File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/base.py", line 134, in stream_response return await super().stream_response(send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/responses.py", line 262, in stream_response async for chunk in self.body_iterator: File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/base.py", line 98, in body_stream raise app_exc File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/base.py", line 70, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in call raise exc File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in call await self.app(scope, receive, sender) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call raise e File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/routing.py", line 706, in call await route.handle(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/routing.py", line 443, in handle await self.app(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/applications.py", line 271, in call await super().call(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/applications.py", line 118, in call await self.middleware_stack(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in call raise exc File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in call await self.app(scope, receive, _send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in call raise exc File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in call await self.app(scope, receive, sender) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call raise e File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/routing.py", line 706, in call await route.handle(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/starlette/routing.py", line 66, in app response = await func(request) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/routing.py", line 237, in app raw_response = await run_endpoint_function( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi/routing.py", line 163, in run_endpoint_function return await dependant.call(**values) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/fastapi_amis_admin/crud/_sqlmodel.py", line 471, in route data.total = await self.db.async_scalar( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/session.py", line 241, in scalar result = await self.execute( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/session.py", line 215, in execute result = await greenlet_spawn( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 126, in greenlet_spawn result = context.throw(sys.exc_info()) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlmodel/orm/session.py", line 101, in execute return super().execute( # type: ignore File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1712, in execute result = conn._execute_20(statement, params or {}, execution_options) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_20 return meth(self, args_10style, kwargs_10style, execution_options) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 333, in _execute_on_connection return connection._execute_clauseelement( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1572, in _execute_clauseelement ret = self._execute_context( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context self.handle_dbapi_exception( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2124, in handle_dbapi_exception util.raise( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 208, in raise raise exception File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context self.dialect.do_execute( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 479, in execute self.adapt_connection.await( File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only return current.driver.switch(awaitable) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn value = await result File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 454, in _prepare_and_execute self._handle_exception(error) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 389, in _handle_exception self._adapt_connection._handle_exception(error) File "/Users/yu/.conda/envs/turingmodel/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 682, in _handle_exception raise translated_error from error sqlalchemy.exc.DBAPIError: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.InFailedSQLTransactionError'>: current transaction is aborted, commands ignored until end of transaction block [SQL: SELECT count(%s) AS count_1 FROM (SELECT "user".id AS id FROM "user") AS anon_1] [parameters: ('',)] (Background on this error at: https://sqlalche.me/e/14/dbapi)

yxlwfds avatar Jul 08 '23 15:07 yxlwfds