· 9 years ago · Oct 01, 2016, 06:30 AM
1"""
2This file contains all of the configuration values for the application.
3Update this file with the values for your specific Google Cloud project.
4You can create and manage projects at https://console.developers.google.com
5"""
6
7import os
8
9# The secret key is used by Flask to encrypt session cookies.
10SECRET_KEY = 'secret'
11
12# There are three different ways to store the data in the application.
13# You can choose 'datastore', 'cloudsql', or 'mongodb'. Be sure to
14# configure the respective settings for the one you choose below.
15# You do not have to configure the other data backends. If unsure, choose
16# 'datastore' as it does not require any additional configuration.
17DATA_BACKEND = 'cloudsql'
18
19# Google Cloud Project ID. This can be found on the 'Overview' page at
20# https://console.developers.google.com
21PROJECT_ID = '****-*****'
22
23# CloudSQL & SQLAlchemy configuration
24# Replace the following values the respective values of your Cloud SQL
25# instance.
26CLOUDSQL_USER = 'root'
27CLOUDSQL_PASSWORD = '***********'
28CLOUDSQL_DATABASE = '**********'
29# Set this value to the Cloud SQL connection name, e.g.
30# "project:region:cloudsql-instance".
31# You must also update the value in app.yaml.
32CLOUDSQL_CONNECTION_NAME = '***-***:*****:*****'
33
34# The CloudSQL proxy is used locally to connect to the cloudsql instance.
35# To start the proxy, use:
36#
37# $ cloud_sql_proxy -instances=your-connection-name=tcp:3306
38#
39# Alternatively, you could use a local MySQL instance for testing.
40LOCAL_SQLALCHEMY_DATABASE_URI = (
41 'mysql+pymysql://{user}:{password}@localhost/{database}').format(
42 user=CLOUDSQL_USER, password=CLOUDSQL_PASSWORD,
43 database=CLOUDSQL_DATABASE)
44
45# When running on App Engine a unix socket is used to connect to the cloudsql
46# instance.
47LIVE_SQLALCHEMY_DATABASE_URI = (
48 'mysql+pymysql://{user}:{password}@localhost/{database}'
49 '?unix_socket=/cloudsql/{connection_name}').format(
50 user=CLOUDSQL_USER, password=CLOUDSQL_PASSWORD,
51 database=CLOUDSQL_DATABASE, connection_name=CLOUDSQL_CONNECTION_NAME)
52
53if os.environ.get('GAE_APPENGINE_HOSTNAME'):
54 SQLALCHEMY_DATABASE_URI = LIVE_SQLALCHEMY_DATABASE_URI
55else:
56 SQLALCHEMY_DATABASE_URI = LOCAL_SQLALCHEMY_DATABASE_URI