Python MySQL Create Database

Posted by  Franco Falkov
 489  View(s)
Ratings:
Rate this:

How to Create Database MySQL in Python ?

  1. Re: Python MySQL Create Database

    Python needs a MySQL driver to access the MySQL database.

    In this tutorial we will use the driver "MySQL Connector". 

    We recommend that you use PIP to install "MySQL Connector installation of mysql connector : 

    C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>python -m pip install mysql-connector 

    DataBase connector import in system :

    import mysql.connector 

    example : 

    mydb = mysql.connector.connect( 
      host="localhost",
      user="yourusername",
      passwd="yourpassword"
    )
    mycursor = mydb.cursor()
    mycursor.execute("CREATE DATABASE mydatabase")

Answer