Python Forum
Psycopg2 import files from another map
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Psycopg2 import files from another map
#1
For a school project I'm working with Psycopg2 and PostgreSQL. However, when I try to run
connection = psycopg2.connect("dbname=NAME user=USER password=PASSWORD"
I get the error

File "C:\Program Files\Python35\lib\site-packages\psycopg2\__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL:  database "NAME" does not exist

I believe this is because the database is located in another map, but I can't find how to access this map anywhere. I've tried using cd .. but this also won't work for me.

Does anyone know how I can access files in another map with Psycopg2, or tell me where I'm going wrong?

Thanks!
Reply
#2
Hello,
NAME, USER and PASSWORD are default parameters for dbname, user and passoword arguments respectively. Your call to psycopg2.connect must include your particular information, something like:
connection = psycopg2.connect("dbname=my_database user=BluezamX password=top_secret")
You may also need to provide an IP (most likely localhost). And of course, that particular database and user must exist, and Postgres must be running. More info is available on docs page:
http://initd.org/psycopg/docs/module.htm...g2.connect
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020