Tuesday, May 3, 2022

python with mysql topic 1(How to create db)

 using python we can create our on DB using python in mysql.

please follow the below lines of code

import pymysql

#create the database connections

con =  pymysql.connect(host ="localhost",user = "root",password='')

#create the cursor object

cursor =  con.cursor()

#execute the query

cursor.execute('CREATE DATABASE ANIL2')

#print the statement

print("database created successfully")



copy the above lines in Any python IDE, open mysql server. then run the above code you will see the Anil2 Database in Mysql

python class topic video