title: ModuleNotFoundError: No module named 'MySQLdb' in Flask-sqlalchemy
body: <p>I am just new in Flask, so I am trying to send data to the database using different tutorial source. I build simple blog type websites and my database server is <code>http://localhost/phpmyadmin/</code>. After I clicked on the submit button on contact.html. I got this error. So how can I fixed this error.</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\util\_collections.py&quot;, line 1020, in __call__
      return self.registry[key]
  KeyError: 6528
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 2464, in __call__
      return self.wsgi_app(environ, start_response)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 2450, in wsgi_app
      response = self.handle_exception(e)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 1867, in handle_exception
      reraise(exc_type, exc_value, tb)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py&quot;, line 39, in reraise
      raise value
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 2447, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 1952, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 1821, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py&quot;, line 39, in reraise
      raise value
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 1950, in full_dispatch_request
      rv = self.dispatch_request()
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py&quot;, line 1936, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File &quot;F:\Flask\01\tut1.py&quot;, line 33, in contact
      db.session.add(entry)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\orm\scoping.py&quot;, line 163, in do
      return getattr(self.registry(), name)(*args, **kwargs)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\util\_collections.py&quot;, line 1022, in __call__
      return self.registry.setdefault(key, self.createfunc())
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\orm\session.py&quot;, line 3286, in __call__
      return self.class_(**local_kw)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py&quot;, line 138, in __init__
      bind = options.pop('bind', None) or db.engine
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py&quot;, line 943, in engine
      return self.get_engine()
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py&quot;, line 962, in get_engine
      return connector.get_engine()
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py&quot;, line 556, in get_engine
      self._engine = rv = self._sa.create_engine(sa_url, options)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_sqlalchemy\__init__.py&quot;, line 972, in create_engine
      return sqlalchemy.create_engine(sa_url, **engine_opts)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\engine\__init__.py&quot;, line 500, in create_engine
      return strategy.create(*args, **kwargs)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\engine\strategies.py&quot;, line 87, in create
      dbapi = dialect_cls.dbapi(**dbapi_args)
    File &quot;C:\Users\New Tech\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\sqlalchemy\dialects\mysql\mysqldb.py&quot;, line 118, in dbapi
      return __import__(&quot;MySQLdb&quot;)
  ModuleNotFoundError: No module named 'MySQLdb'
  </code></pre>
  <p><strong>My code is here</strong></p>
  <pre><code>from flask import Flask, render_template, request
  from flask_sqlalchemy import SQLAlchemy
  from datetime  import datetime
  
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:@localhost/blog'
  db = SQLAlchemy(app)
  
  class Contacts(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(80), nullable=False)
      email = db.Column(db.String(255), nullable=False)
      phone_number = db.Column(db.String(50), nullable=False)
      message = db.Column(db.String(120), nullable=False)
      date_created = db.Column(db.String(50), nullable=True )
  
  
  @app.route('/contact/', methods=['GET','POST'])
  def contact():
      if request.method == 'POST':
          name = request.form.get('name')
          email = request.form.get('email')
          phone_number = request.form.get('phone_number')
          message = request.form.get('message')
          entry = Contacts(name=name, email=email, phone_number=phone_number, message=message, date_created=datetime.now())
          db.session.add(entry)
          db.session.commit()
      return render_template('contact.html')
  
  app.run(debug=True)
  </code></pre>
  <p><strong>Does anyone knows, how I get this error ?</strong></p>