Running Django on the App Engine standard environment Error : database does not exist in local

Hello,

I'm looking for some help after days of research.
I followed the tutorial "Running Django on the App Engine standard environment" and I'm blocked at the step Run the app on your local computer (https://cloud.google.com/python/django/appengine#run-locally)

when I run the comand below :

python manage.py makemigrations

it return me the error : 
Got an error checking a consistent migration history performed for database connection 'default': connection to server at "127.0.0.1", port 5432 failed: FATAL: database "databasebydefaut " does not exist

But I can connect when I used the code : psql -h 127.0.0.1 -p 5432 -U firstuser -d databasebydefaut

I can connect to when I modify  the settings.py without .env file and without security manager process 
settings.py setup : 

# Database configuration
SECRET_KEY = os.getenv('SECRET_KEY', 'mysecretkey')
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': os.getenv('DB_NAME', 'databasebydefaut'),
        'USER': os.getenv('DB_USER', 'firstuser'),
        'PASSWORD': os.getenv('DB_PASSWORD', 'psk***'),  # Remplacez par votre mot de passe
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

and apply the following lines in comand line : 

set DB_NAME=databasebydefaut
set DB_USER=firstuser
set DB_PASSWORD=psk***
set SECRET_KEY=mysecretkey
set DEBUG=False

python manage.py makemigrations
python manage.py migrate
python manage.py runserver

I'm on windows 11.
I tried to run from scratch many times the tutorial,
by running through windows comand line
by running through gcould

I think there is a problem of communication with Secret Manager process.

Does anyone experienced this issue ?

0 1 59
1 REPLY 1

Hi,

If you "exactly" followed the steps in that tutorial, then the issue might be that the tutorial expects you to connect to a DB created in the cloud but it looks like you're using a local DB (created on your machine).

The tutorial talks about downloading/installing "Cloud SQL Auth Proxy"

When deployed, your app uses the Cloud SQL Auth Proxy that is built into the App Engine standard environment to communicate with your Cloud SQL instance. However, to test your app locally, you must install and use a local copy of the proxy in your development environment..... 

So, if you're using the sql auth proxy, you either have to figure out how to make it connect to a local DB (don't know if that's possible) or you disable it and connect to your local DB. The other option is that you follow the steps in the tutorial and create your DB in the cloud and then a local test of your App will connect to the cloud DB via the Cloud SQL Auth Proxy

 

    ......NoCommandLine ......
https://nocommandline.com
        Analytics & GUI for 
App Engine & Datastore Emulator