title: Unable to make Flask-SQLAlchemy connect to my Google App Engine DB
body: <p>I am trying to set up a web-application based on Flask using Google App Engine (I'm new to both).
  The web-application receives data from the client and it should be processed and saved in a database.</p>
  
  <p>I've tried to use Flask-SQLAlchemy but I'm unable to set it up with Google Cloud SQL, I've used <a href="https://cloud.google.com/sql/docs/create-instance#create-2nd-gen" rel="nofollow noreferrer">this guide</a> to create a MySQL DB in the same project:</p>
  
  <p><img src="https://i.stack.imgur.com/vMDRA.png" alt="DB on GAE"></p>
  
  <p>and then I'm trying to use it on my main python code:</p>
  
  <pre><code>app.config('SQLALCHEMY_DATABASE_URI') = 'mysql+mysqldb://root@/Results?unix_socket=/cloudsql/crafty-circlet-164415:psy01'
  app.config['SECRET_KEY'] = 'NglfxE8FOP9pgV8fxpyj'
  db = SQLAlchemy(app)
  
  class Result(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.Text)
      profession = db.Column(db.Text)
      year = db.Column(db.Text)
      pressure_level = db.Column(db.Integer)
      reported_suc_count = db.Column(db.Integer)
      marked_suc_count = db.Column(db.Integer)
      real_suc_count = db.Column(db.Integer)
      insertion_time = db.Column(db.DateTime)
  
      def __init__(self, name, profession, year, pressure_level, reported_suc_count, marked_suc_count, real_suc_count):
          self.name = name
          self.profession = profession
          self.year = year
          self.pressure_level = pressure_level
          self.reported_suc_count = reported_suc_count
          self.marked_suc_count = marked_suc_count
          self.real_suc_count = real_suc_count
          self.insertion_time = datetime.utcnow()
  
  @app.route('/resultform', methods=['POST', 'GET'])
  def resultform():
      if request.method == 'POST':
          if not request.form['successmatrices']:
              flash('please fill all the fields', 'error')
          else:
              if 'name' in request.form:
                  name = request.form['name']
              else:
                  name = None
              if 'profession' in request.form:
                  profession = request.form['profession']
              else:
                  profession = None
              if 'year' in request.form:
                  year = request.form['year']
              else:
                  year = None
              if 'pressure_level' in request.form:
                  pressure_level = int(request.form['pressure_level'])
              else:
                  pressure_level = None
              if 'successmatrices' in request.form:
                  successmatrices = int(request.form['successmatrices'])
              else:
                  successmatrices = 0
              new_result = Result(name=name, profession=profession, year=year, pressure_level=pressure_level, reported_suc_count=successmatrices, marked_suc_count=len(session['marked']), real_suc_count=len(session['correct']))
              db.session.add(new_result)
              db.session.commit()
              return redirect(url_for('showresults'))
      return render_template("resultform.html")
  
  @app.route('/showresults')
  def showresults():
      return render_template("showresults.html", results=Results.query.all())
  
  if __name__ == '__main__':
      db.create_all()
      app.run(debug=True)
  </code></pre>
  
  <p>When I'm trying to run it in my local development (I'm using PyCharm) I receive the following error in the background:</p>
  
  <pre><code>ERROR    2017-04-16 09:20:19,802 wsgi.py:263] 
  Traceback (most recent call last):
    File "C:\Users\&lt;&gt;\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
      handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
    File "C:\Users\&lt;&gt;\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
      handler, path, err = LoadObject(self._handler)
    File "C:\Users\&lt;&gt;\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
      obj = __import__(path[0])
    File "C:\Users\&lt;&gt;\PycharmProjects\crafty-circlet-164415\main.py", line 7
      app.config('SQLALCHEMY_DATABASE_URI') = 'mysql+mysqldb://root@/Results?unix_socket=/cloudsql/crafty-circlet-164415:psy01'
  SyntaxError: can't assign to function call
  </code></pre>
  
  <p>And after deployment to GAE the following error appears: </p>
  
  <pre><code>Error: Server Error
  The server encountered an error and could not complete your request.
  
  Please try again in 30 seconds.
  </code></pre>
  
  <p>Any idea how to solve this? </p>