Reputation: 299
I want ot connect externally via psycopg2 to Azure postgresql. I have created a server with postgresql db on it. The problem is that when I try to create a connection the error comes up saying that 'psycopg2.OperationalError: FATAL: The server name you tried cannot be found. Please use the correct name and retry. Please check your server name lfsserverlv.'
import psycopg2
conn = psycopg2.connect(
host='lfsserverlv.database.windows.net',
dbname='lfsdb',
user='adminlfs@lfsserverlv',
password='some_password',
sslmode='require'
)
The server name is on the screenshot below (Sorry for Russian in it) There should be something else I pobably don't know on connections to Azure. Any help would be greatly appreciated
Upvotes: 1
Views: 2110
Reputation: 12768
Make sure you have passed the correct server name.
Get the connection information needed to connect to the Azure Database for PostgreSQL. You need the fully qualified server name and login credentials.
By using the above connection information, I'm able to connect Azure Database for PostgreSQL using python as follows:
For more details, refer "Connect Azure Database for PostgreSQL using Python".
Hope this helps.
Upvotes: 1