N
Neon•2y ago
adverse-sapphire

Unable to connect via psycopg2

Hi, In my python project I'm trying to connect to my neon database using psycopg2. I've followed this tutorial in a competely new project https://neon.tech/docs/guides/python But I keep ending up with this error: psycopg2.OperationalError: could not translate host name "iHET@ep-fragrant-term-a21bvidu.eu-central-1.aws.neon.tech" to address: A non-recoverable error occurred during a database lookup. As far as the connection string I am using, I do as the guide says and the one from the dashboard of my database and then i put in the password for my account in place of the stars. Anybody tried something similar?
Neon
Connect a Python application to Neon using Psycopg - Neon Docs
This guide describes how to create a Neon project and connect to it from a simple Python application using Psycopg (psycopg2), a popular Postgres database adapter for the Python programming language. ...
3 Replies
eastern-cyan
eastern-cyan•2y ago
Looks like you have configured your connection string incorrectly as it's unable to parse the hostname from it.
As far as the connection string I am using, I do as the guide says and the one from the dashboard of my database and then i put in the password for my account in place of the stars.
In the console UI, can you instead try click the clipboard icon? it will do this for you, so you don't need to fiddle with it. It will look something like
DATABASE_URL='postgres://conrad:verycoolpassword@ep-cool-database.eu-central-1.aws.neon.tech/database?sslmode=require'
DATABASE_URL='postgres://conrad:verycoolpassword@ep-cool-database.eu-central-1.aws.neon.tech/database?sslmode=require'
eastern-cyan
eastern-cyan•2y ago
specifically, this clipboard icon, highlighted in blue.
No description
adverse-sapphire
adverse-sapphireOP•2y ago
@Conrad Ludgate That did the trick. I was pasting in the wrong password, lol. Thank you for your help! 🙏 '

Did you find this page helpful?