I'm trying to work with db. So I connect to the PostgreSQL database with the following connection info. I'm using Jupyter Notebook.
from sqlalchemy import create_engine
POSTGRES_DIALECT = 'postgresql'
POSTGRES_SERVER = 'server'
POSTGRES_DBNAME = 'db'
POSTGRES_SCHEMA = 'public'
POSTGRES_USERNAME = 'user'
POSTGRES_PASSWORD = 'password'
postgres_str = ('{dialect}://{username}:{password}@{server}/{dbname}'.format(
dialect=POSTGRES_DIALECT,
server=POSTGRES_SERVER,
dbname=POSTGRES_DBNAME,
username=POSTGRES_USERNAME,
password=POSTGRES_PASSWORD
))
# Create the connection
cnx = create_engine(postgres_str)
agreements_df = pd.read_sql_query('''SELECT * from db''', cnx)
agreements_df.head()
There's the error:
OperationalError: (psycopg2.OperationalError) could not translate host name "server" to address: nodename nor servname provided, or not known