FastAPI-Backend-Template icon indicating copy to clipboard operation
FastAPI-Backend-Template copied to clipboard

AttributeError: 'pydantic_core._pydantic_core.MultiHostUrl' object has no attribute 'replace'

Open eshpilevskiy opened this issue 2 years ago • 1 comments

backend_app | File "/usr/backend/src/repository/database.py", line 42, in backend_app | async_db: AsyncDatabase = AsyncDatabase() backend_app | ^^^^^^^^^^^^^^^ backend_app | File "/usr/backend/src/repository/database.py", line 19, in init backend_app | url=self.set_async_db_uri, backend_app | ^^^^^^^^^^^^^^^^^^^^^ backend_app | File "/usr/backend/src/repository/database.py", line 36, in set_async_db_uri backend_app | self.postgres_uri.replace("postgresql://", "postgresql+asyncpg://") backend_app | ^^^^^^^^^^^^^^^^^^^^^^^^^ backend_app | AttributeError: 'pydantic_core._pydantic_core.MultiHostUrl' object has no attribute 'replace'

eshpilevskiy avatar Nov 28 '23 11:11 eshpilevskiy

change it to: self.postgres_uri.unicode_string().replace("postgresql://", "postgresql+asyncpg://")

krawalli avatar Feb 03 '24 20:02 krawalli