itself we wrap the python code into tary except block and use the built-in error codes of mysql to tell us if anything went wrong we can verify that this block works by executing the database-creating code twice the first timeit will create new database in mysqland the second time it will print out an error message stating that this database already exists we can verify which databases exist by executing the following mysql command using the very same cursor object syntax instead of issuing the create database commandwe create cursor and use it to execute the show database commandthe result of which we fetch and print to the console output import mysql connector as mysql import guidbconfig as guiconf unpack dictionary credentials conn mysql connect(**guiconf dbconfigcursor conn cursor(cursor execute("show databases"print(cursor fetchall()conn close( running this code shows us which databases currently exist in our mysql server instance as we can see from the outputmysql ships with several built-in databasessuch as information_schema and so on we have successfully created our owuidb databasewhich is shown in the output all other databases illustrated come shipped with mysql using the insert command creating new databases import mysql connector #create the connection object myconn mysql connector connect(host "localhost"user "root", asswd "google" #creating the cursor object