2017-09-21 1 views
0

Google App Engine에 django-backend가있는 웹 사이트를 배포하고 있습니다. 나는 그들 tutorial을 따라 갔다. MySQL을 사용하여 로컬 서버에서 웹 사이트를 실행했으며 완벽하게 실행됩니다. 구글 앱 엔진에 배포 그것은 나에게 다음과 같은 오류를 제공하는 경우 는 :Google App Engine Django : 배포 후 Google Cloud SQL에서 테이블을 만들 수 없습니다.

if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'): 
    DATABASES = { 
     'default': { 
      'ENGINE': 'django.db.backends.mysql', 
      'NAME': 'database_name', 
      'USER': 'user_name', 
      'PASSWORD': 'password', 
      'HOST': '/cloudsql/copied perfectly from google cloud sql instance', 

     } 
    } 
else: 

    DATABASES = { 
      'default': { 
       'ENGINE': 'django.db.backends.mysql', 
       'HOST': '127.0.0.1', 
       'PORT': '3306', 
       'NAME': 'database_name', 
       'USER': 'username', 
       'PASSWORD': 'password', 
         } 
       }   

: 여기

# [START django_app] 
runtime: python27 
api_version: 1 
threadsafe: yes 

handlers: 
- url: /static 
    static_dir: static/ 
- url: .* 
    script: wt.wsgi.application 

# Only pure Python libraries can be vendored 
# Python libraries that use C extensions can 
# only be included if they are part of the App Engine SDK 
# Using Third Party Libraries: https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27 
libraries: 
- name: MySQLdb 
    version: 1.2.5 
- name: django 
    version: "1.11" 

env_variables: 
    CLOUDSQL_CONNECTION_NAME: 'copied perfectly from google cloud sql instance' 
    CLOUDSQL_USER: username 
    CLOUDSQL_PASSWORD: password 

# [END django_app] 

# Google App Engine limits application deployments to 10,000 uploaded files per 
# version. The skip_files section allows us to skip virtual environment files 
# to meet this requirement. The first 5 are the default regular expressions to 
# skip, while the last one is for all env/ files. 
skip_files: 
- ^(.*/)?#.*#$ 
- ^(.*/)?.*~$ 
- ^(.*/)?.*\.py[co]$ 
- ^(.*/)?.*/RCS/.*$ 
- ^(.*/)?\..*$ 
- ^env/.*$ 

내 settings.py입니다 : 여기
ProgrammingError "Table 'clouddatabasename'.'appname'_'modelname' doesn't exist" 

내 애플리케이션 제목입니다 친절하게 도와주세요. 내 모델/테이블을 Google App Engine에서 사용할 수없는 이유를 모르겠습니다. 미리 감사드립니다!

답변

1

단계를 수행했다고하셨습니다. 마이그레이션을 만들고 실행할 때 Cloud SQL Proxy를 실행 했습니까? 실행 중이 아니거나 올바르게 구성되지 않은 경우 로컬 데이터베이스에서 마이그레이션이 제대로 실행되었지만 Cloud 데이터베이스에 마이그레이션되지 않은 이유를 설명합니다.

+1

'cloud_sql_proxy.exe -instances = "[YOUR_INSTANCE_CONNECTION_NAME]"= tcp : 3306' "이 단계는 로컬 컴퓨터와 로컬 컴퓨터의 Cloud SQL 인스턴스에 대한 연결을 설정합니다 응용 프로그램을 로컬에서 테스트 할 때마다 Cloud SQL Proxy가 실행되도록하십시오. " 응용 프로그램을 로컬에서 테스트해야 할 때만 Cloud SQL Proxy를 사용해야한다고 말합니다. – Maverick7

+0

감사합니다! 당신이 옳았! Google은 설명서를 명확하게 작성해야합니다. – Maverick7

0
  1. Google SQL 콘솔에서 데이터베이스를 삭제하십시오.
  2. python manage.py makemigrations
  3. python manage.py migrate
  4. 다시 응용 프로그램 테스트를 배포 마이그레이션 만들어 다시 모든 마이그레이션을 제거하고.
+0

나는 당신이 말한대로했는데 여전히 같은 오류가 발생합니다. 내가 makemigrations 할 때 마이 그 레이션하면 Google Cloud Database가 아닌 내 로컬 데이터베이스에 새로운 마이그레이션이 생성됩니다. gcloud app deploy' 이전과 같은 것을 배포하고 있습니다. – Maverick7

관련 문제