title: Flask cannot connect to RDS MySQL
body: <p>I used flask-sqlalchemy with PostgreSQL.
  Now, I switched to RDS MySQL,
  so I changed SQLALCHEMY_DATABASE_URI
  form</p>
  
  <pre><code>app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://**************'
  </code></pre>
  
  <p>to</p>
  
  <pre><code>app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://{username}:{password}@{endpoint}:{port}?charset=utf8"
  </code></pre>
  
  <p>after this, I initialize app like this</p>
  
  <pre><code>from flask import Flask, render_template, request, logging, Response, redirect, flash, jsonify
  from flask_cors import CORS
  from flask_sqlalchemy import SQLAlchemy
  from flask_marshmallow import Marshmallow
  
  app = Flask(__name__)
  
  db = SQLAlchemy(app)
  ma = Marshmallow(app)
  
  class User(db.Model):
      __tablename__ = 'user'
      id = db.Column(db.String(8),  primary_key=True)
      name = db.Column(db.String, unique=False)
      email = db.Column(db.String, unique=False)
  
      def __init__(self,params):
          self.id = params['id']
          self.name = params['name']
          self.email = params['email']
  
  class UserSchema(ma.ModelSchema):
      class Meta:
          model = User
  
  @app.route('/get_user', methods=['GET'])
  def get_user():
      userid = request.args['id']
      user = User.query.get(userid)
      return user
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p>But the app cannot connect to server.
  (I confirmed username, password, endpoint, port, is correct and connected from mysql workbench)</p>
  
  <p>I read this question.
  <a href="https://stackoverflow.com/questions/27766794/switching-from-sqlite-to-mysql-with-flask-sqlalchemy">Switching from SQLite to MySQL with Flask SQLAlchemy</a>
  so I installed pymysql, but it didn't work.</p>
  
  <p>When my app tried to connect db, this error message is shown.
  it seems that psycopg2 is called although I'm using mysql.</p>
  
  <p>Could you please give me some advise?</p>
  
  <pre><code>psycopg2.ProgrammingError: invalid dsn: invalid connection option "mysql+pymysql://mysql+pymysql://{username}:{password}{endpoint}:{port}?charset"
  </code></pre>