How can I integrate flask-sqlalchemy with Google Cloud Functions and something like Cloud SQL?
Looking at the minimal application example, it wraps the app variable:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
def __repr__(self):
return '<User %r>' % self.username
But my Google Cloud Function doesn't have access to anything called app:
def my_function(request):
return "Hello world!"
Creating my own app with app = Flask(__name__) doesn't work as this app isn't used by Cloud Functions to return the response.