title: Deploying Flask sqlalchemy apps in AWS lambda and API gateway
body: <p>I am not able to find good resources which can help me understand how can i migrate my Flask and sqlalchemy apps to AWS lambda and API gateway and make it serverless. Like for instance below is a sample code taken from the flask_sqlalchemy documentation :</p>
  
  <pre><code>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 '&lt;User %r&gt;' % self.username
  </code></pre>
  
  <p>Now how can i migrate this code to AWS lambda . Is it even possible . For instance the line <code>app = Flask(__name__)</code> should not be there right ? If there is no app variable how am i going to initialize db variable ?</p>
  
  <p>Please can someone give me some intro or a link to a good tutorial which will clear these concepts?</p>
  
  <p>Many thanks in advance.</p>