1 from os import environ
2 debug = not environ.get("APP_NAME", "")
3 if debug:
4 #LOCAL
5 db_name = "本地数据库名"
6 name = "mysql的用户名"
7 pwd = "用户登录mysql的密码"
8 host = "127.0.0.1"
9 port = "3306"
10 else:
11 #SAE
12 import sae.const
13 db_name = sae.const.MYSQL_DB
14 name = sae.const.MYSQL_USER
15 pwd = sae.const.MYSQL_PASS
16 host = sae.const.MYSQL_HOST
17 port = sae.const.MYSQL_PORT
18 host_s = sae.const.MYSQL_HOST_S
19
20 DATABASES = {
21 'default': {
22 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
23 'NAME': db_name, # Or path to database file if using sqlite3.
24 'USER': name, # Not used with sqlite3.
25 'PASSWORD': pwd, # Not used with sqlite3.
26 'HOST': host, # Set to empty string for localhost. Not used with sqlite3.
27 'PORT': port, # Set to empty string for default. Not used with sqlite3.
28 }
29 }
我这里的设置是: