Databases - JWalshe86/career GitHub Wiki
Heroku Database Postgres
settings.py settings for pg db local & heroku
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
if "DATABASE_URL" in os.environ:
DATABASES = {"default": dj_database_url.parse(os.environ.get("DATABASE_URL"))}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'd539b1lf93j941',
'USER': 'u49a84fn70nj9o',
'PASSWORD':'pfd06cbf442bb444875c0b8a03a29c5ac62151d659c19da3582df4e283f4150c9',
'HOST': 'c9tiftt16dc3eo.cluster-czz5s0kz4scl.eu-west-1.rds.amazonaws.com',
'PORT': '5432',
}
}
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
'NAME': 'test_db',
'USER': 'root',
'PASSWORD': 'Sunshine7!',
'HOST': 'localhost',
'PORT': '3306',
}
}
Type into terminal
pgadmin4
Username = [email protected] Password = default User postgres & password default
To view or modify data, right click on a table or view name in the Object Explorer. When the context menu opens, use the View/Edit Data menu to specify the number of rows you would like to display in the editor panel.
This shows not data for jobsearch
All working on heroku now
🎉 🎉 🎉
I had to grant all permissions to the encrypted heroku user
GRANT CONNECT ON DATABASE postgres TO u49a84fn70nj9o;
Then give it a password
ALTER USER postgres with encrypted password 'Sunshine7!';
*** psql on the terminal seems to have given these commands automatically
import pprint # Makes it sooo pretty :)
from django.db import connection
print(pprint.pformat(connection.settings_dict))
Shows a different db is being used...
Connect to heroku db using pgadmin
Heroku has a page with all postgres db settings.
Found data relating to heroku & local in pgadmin
Changes made in UI now reflected in pgadmin