every time i try to make connection between python and PSQL this error disappear ?
2 Answers
Looking at the information provided the issue could be the os.getenv("DATABASE_URL")
which evaluates to None
in the event of non existent environment variable. Hence, double check whether you have set the DATABASE_URL
in your environment.
I noticed that the 2018 lecture for SQL only specified to set the database URL to ours but didn't go through it. I was able to run the code after doing the following (I'm using Linux and Python3):
1. Install psycopg2 within pip $ sudo pip3 install psycopg2
2. Set DATABASE_URL $ export DATABASE_URL="postgresql:///(database name)"
note that other sources say that it's "postgresql://localhost/(database name) but my code worked when I omitted the localhost
3. Run the python file.
u
is aNoneType
, which does not have an attribute_instantiate_plugins
. It seems likely, then, thatu
is not instantiated as the object you think it is.