2024-10-14-Monday


created: 2024-10-14 07:42 tags: - daily-notes


Monday, October 14, 2024

<< Timestamps/2024/10-October/2024-10-13-Sunday|Yesterday | Timestamps/2024/10-October/2024-10-15-Tuesday|Tomorrow >>


🎯 Goal

  • [ ] Identify the first issue I want to solve

🌟 Results

  • Couldn't focus on solving a single issue, but played around with PostgreSQL access via pgadmin.
  • Closed out the SSL Cert Issue that seems to have resolved itself.

🌱 Next Time

  • Identify the first issue I want to solve and start solving it.

📝 Notes

Decided to take another look at the issues I set up a couple weeks ago. I re-connected to the Production version of the PostgreSQL database and managed to get the live version of the data. I'd like to hook this up to the DIMMiN App in my Staging environment so that I can have a read-only copy of all the data in my production environment. To do that I want to create a read-only user in SQL:

-- Create the read-only user
CREATE USER read_only_user WITH PASSWORD 'your_password';

-- Grant CONNECT privileges
GRANT CONNECT ON DATABASE your_database_name TO read_only_user;

-- Grant read-only access to all tables
GRANT USAGE ON SCHEMA public TO read_only_user;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO read_only_user;

-- Ensure future tables are also read-only
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO read_only_user;

Then re-configure my config/settings.py file to include access to this database to go from this

# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
# Use SQLlite during development
if DEBUG:
    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
# Use PostgreSQL in Production
else:
    DATABASES = {
        "default": dj_database_url.config(
            default=env.dj_db_url("DATABASE_URL"), 
            conn_max_age=600
        )
}

To this:

import os
import dj_database_url
from dotenv import load_dotenv

load_dotenv()

# Database Configuration
if DEBUG:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': 'your_database_name',
            'USER': 'read_only_user',  # A read-only user
            'PASSWORD': os.getenv('DB_PASSWORD'),
            'HOST': 'your_remote_db_host',
            'PORT': 'your_db_port',
        }
    }
else:
    # Use PostgreSQL in Production
    DATABASES = {
        "default": dj_database_url.config(
            default=env.dj_db_url("DATABASE_URL"), 
            conn_max_age=600
        )
    }

Only issue with this could be that credentials in Heroku will rotate, meaning I may have to adjust / update these which could quickly become a pain. This may be the first issue I solve, mostly because it would help solve a major flaw in the DIMMiN App (which is that I just free-wheel it and push updates to production before checking whether anything will break). It will also be far more useful to write to the Blog App given that I can now directly associate a Blog Post and its relevant Javascript / D3 code.


Notes created today

List FROM "" WHERE file.cday = date("2024-10-14") SORT file.ctime asc

Notes last touched today

List FROM "" WHERE file.mday = date("2024-10-14") SORT file.mtime asc

(Template referenced from Dann Berg, can be found here)


Previous Note 2024-10-04-Friday Next Note 2024-11-05-Tuesday