problem with postgres+asyncpg default connector #2333
-
|
I am trying to connect TruSession to a postgres+asyncpg database. I used this link as reference. Right after I see that it TruSession was initialized with my db url, I am getting a traceback (below). Is it possible to have a asyncpg postgres as default connector instead of the default sqlite. Note: I want to have OTEL enabled. Traceback (most recent call last): |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
TruSession and DefaultDBConnector currently only support synchronous SQLAlchemy engines and database URLs, like To connect to PostgreSQL, use the synchronous psycopg driver as shown in the docs and examples source. If you need async database support, you would need to refactor the connector and session logic to work with async SQLAlchemy engines and asyncpg, which is not currently supported. OTEL tracing is enabled by default and works with the supported synchronous connectors. There is no special configuration for async database connections, since async is not supported source. For now, use the synchronous psycopg driver for PostgreSQL with TruSession. If you need async database operations, consider isolating those from TruSession logging, or use a separate logging mechanism. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Hi @Milanomac - We've added PostgreSQL support using the synchronous psycopg2 driver. Expecting this to make TruLens 2.6 release this week.
The asyncpg driver you were using requires SQLAlchemy's async extension, which TruLens doesn't support yet. However, for most use cases, the sync driver works great - TruLens already handles recording and feedback evaluation in background threads, so you shouldn't see any blocking on your main application.
If your application specifically requires the async database support, let me know.