When using PostgreSQL over TLS, what's the recommended way to specify the paths to client cert and key in the postgres connection url? I used ENV_PHOENIX_SQL_DATABASE_URL with a formatted connection url: postgresql://<username>:***@<hostname>/<dbname>?sslcert=<path-to-client-cert>&sslkey=<path-to-client-key>&sslmode=require&sslrootcert=<path-toserver-ca> but got the following error 馃У
馃挕聽Hint: Mention RunLLM in the thread for followups.
It actually looks like sqlalchemy's asyncpg dialect does support this:
import asyncio
import asyncpg
async def async_main():
conn = await asyncpg.connect(
"postgresql://<username>:***@<hostname>/<dbname>?sslcert=%2Fcerts%2Fdb%2Fclient-cert.pem&sslkey=%2Fcerts%2Fdb%2Fclient-key.pem&sslmode=require&sslrootcert=%2Fcerts%2Fdb%2Fserver-ca.pem"
)
row = await conn.fetchrow("SELECT 1")
print(f">>> {row}")
asyncio.run(async_main())^ above script runs fine and return my query result
Maybe try ssl=require (instead of sslmode). I don't use client certs, but that's the parameter that gets it to use TLS.
We're not using client certs, we still/only use password auth
phoenix is using sqlalchemy make_url which does some translation of parameters for different drivers. https://github.com/Arize-ai/phoenix/blob/main/src/phoenix/db/engines.py#L40-L46
You could try passing your input to make_url and see if the output is accepted by the driver
based on my python code above, where I'm using asyncpg.connect directly without sqlalchemy in the middle, the connection was successful
Yeah, so sqlalchemy (used in phoenix) might be changing your URL
Sorry, I don't have much to add. I'll let the phoenix folks comment.
we actually have two pg clients, so this may require some investigation on our end. could you please file us a ticket to track? thanks
Specifically, we found this code block: https://github.com/Arize-ai/phoenix/blob/main/src/phoenix/db/engines.py#L40-L62 I printed out all the url params and they look all good. I see phoenix is overriding driver name here: url.set(drivername="postgresql+asyncpg") , which seems to ask sqlalchemy to use asyncpg dialect -- and it really should work based on this plain vanilla python code below:
import asyncio
import asyncpg
async def async_main():
conn = await asyncpg.connect(
"postgresql://<username>:***@<hostname>/<dbname>?sslcert=%2Fcerts%2Fdb%2Fclient-cert.pem&sslkey=%2Fcerts%2Fdb%2Fclient-key.pem&sslmode=require&sslrootcert=%2Fcerts%2Fdb%2Fserver-ca.pem"
)
row = await conn.fetchrow("SELECT 1")
print(f">>> {row}")
asyncio.run(async_main())Maybe there's a mismatch in the sqlalchemy version phoenix is using?
