try dbs cur execute("show databases" except myconn rollback( for in cur print( myconn close(output fig already existing output import mysql connector #create the connection object myconn mysql connector connect(host "localhost"user "root", asswd "google" #creating the cursor object cur myconn cursor( try #creating new database cur execute("create database pythondb " #getting the list of all the databases which will now include the new database pythondb dbs cur execute("show databases" except myconn rollback(