You can either use
engine = create_engine(os.getenv("DATABSE_URL"))
if you have a system variable already setup, or
engine = create_engine('postgresql://postgres:password@localhost:5432/lecture3')
which provides the direct URL.
I will try to explain.
If you have
import os at the beginning, which makes it possible to call
os.getenv() down the line, then you must set up a system variable with the name
DATABASE_URL because what
os.getenv() does is to go into your system variables and look for a variable called
DATABASE_URL, get its value and parse to
Now, to set up system variable,
On the Windows desktop, right-click My Computer.
In the pop-up menu, click Properties.
In the System Properties window, click the Advanced tab, and then click Environment Variables.
In the System Variables window, click New
Variable name = DATABASE_URL
Variable value = postgresql://postgres:password@localhost:5432/lecture3
This Variable value follows the format
postgres is the default user of the database, so if you have a different user, change it accordingly.
Replace password with the password you created during the setup for postgres.
lecture3 should also be the name of your database
If you have any challenge, try installing a driver like psycopg2.
pip install psycopg2 should do it from your python shell, then try modifying to something like
Variable value = postgresql+psycopg2://postgres:password@localhost:5432/lecture3