Python MySQL Create Database

Total Post:113

Points:791
 81  View(s)
Ratings:
Rate this:

How to Create Database MySQL in Python ?

  1. Post:140

    Points:984
    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!