PyEditorial icon indicating copy to clipboard operation
PyEditorial copied to clipboard

Adding Postgresql as a DB ?

Open ariianebrahiimii opened this issue 3 years ago • 4 comments
trafficstars

In CRMs there are a lot of datastore and being fast is so important, I thought it would be great if we try to add PostgreSQL as a Database to the project and add a Setting to manage and switch between Database as:

# in setting.py
# -- Snip
Postgres = True
if Postgres:
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql_psycopg2',
          'NAME': ‘<db_name>’,
          'USER': '<db_username>',
          'PASSWORD': '<password>',
          'HOST': '<db_hostname_or_ip>',
          'PORT': '<db_port>',
      }
  }
else:
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
      }
  }

Also, we can add Postgres to Docker PR #20
Let me know your opinion and if I can work on it.

AE

ariianebrahiimii avatar Feb 10 '22 16:02 ariianebrahiimii

You've probably noticed that this project is a pilot project designed to teach more Django enthusiasts. For this reason, sqlite3 is used for simplicity. If we want to prepare the project for testing both in the local environment and in the production environment, my suggestion is to connect the database as follows:

if not DEBUG:
    DATABASES = {
        "default": {
            "ENGINE": os.environ.get(
                "DB_ENGINE", "django.db.backends.postgresql"
            ),
            "NAME": os.environ.get("DB_NAME", "postgres"),
            "USER": os.environ.get("DB_USER", "postgres"),
            "PASSWORD": os.environ.get("DB_PASS", "postgres"),
            "HOST": os.environ.get("DB_HOST", "db"),
            "PORT": int(os.environ.get("DB_PORT", "5432")),
        }
    }
else:
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.sqlite3",
            "NAME": os.path.join(BASE_DIR, 'db.sqlite3'),
        }
    }

mavenium avatar Feb 11 '22 07:02 mavenium

Have you added PostgreSQL? Do we need to create a Pull request for it? P.S I have just started contributing to Open source

Bhavyaseth-afk avatar May 22 '22 17:05 Bhavyaseth-afk

You must make the necessary changes to add PostgreSQL to a separate branch and then create a PUll request.

mavenium avatar May 29 '22 04:05 mavenium

You must make the necessary changes to add PostgreSQL to a separate branch and then create a PUll request.

Is the issue still open? I would like to contribute on this. Please see if it could be assigned to me

Bhavyaseth-afk avatar Sep 22 '22 04:09 Bhavyaseth-afk