How to create MySql database using Python

0 votes

Hi Guys,

I am trying to create a MySql database using Python. I have installed MySql connector to my system. How can I do that?

Jul 15, 2020 in Python by akhtar
• 38,260 points
847 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to use MySQL connector in your python code. I have attached one example below for your reference.

import mysql.connector
mydb = mysql.connector.connect(
  host="localhost",
  user="myusername",
  password="mypassword"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE mydatabase")
answered Jul 15, 2020 by MD
• 95,460 points

Related Questions In Python

+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 58,020 points
1,576 views
0 votes
2 answers

How do I connect to a MySQL Database in Python?

connect mysql database with python import MySQLdb db = ...READ MORE

answered Mar 28, 2019 in Python by rajesh
• 1,270 points
1,885 views
0 votes
1 answer

How to create the following pattern using Python?

Hi, @Roshni, You can use two for-loops for ...READ MORE

answered Jun 26, 2020 in Python by Gitika
• 65,770 points
685 views
0 votes
0 answers

How to create Personalised QR code using Python?

How to read and generate QR codes ...READ MORE

Nov 27, 2020 in Python by kartik
• 37,520 points
805 views
0 votes
1 answer

Error:Python3.4 can't install mysql-python

Hello @kartik, You can resolved this by the ...READ MORE

answered Jun 24, 2020 in Python by Niroj
• 82,840 points
2,134 views
0 votes
1 answer

mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported

Hi@akhtar, According to SQL documentation for python library. you ...READ MORE

answered Jul 15, 2020 in Python by MD
• 95,460 points
31,306 views
0 votes
1 answer

ProgrammingError: not all arguments converted during string formatting

Sorted!!!! just found the solution, 1 - apparently ...READ MORE

answered Sep 10, 2018 in Python by Priyaj
• 58,020 points
20,288 views
0 votes
1 answer

Create a database table using python

Hey @Kim, try something like this: import MySQLdb # ...READ MORE

answered Jul 23, 2019 in Python by Barbara
1,264 views
0 votes
1 answer

How to create a database engine using Sqlalchemy in Python?

Hi@akhtar, You can use the Sqlalchemy module in ...READ MORE

answered Jun 26, 2020 in Python by MD
• 95,460 points
1,578 views
0 votes
1 answer

How to insert a date into MySQL using Python?

Hi@akhtar, You can use the DateTime module to insert a date into ...READ MORE

answered Jul 15, 2020 in Python by MD
• 95,460 points
8,216 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP