title: How to get name of a mysql database name from user input and create tables
body: <p>I want to create a mysql database  in python environment and then create tables in it, but the error says that "NO DATABASE SELECTED".how can I fix it?</p>
  
  <pre><code>import mysql.connector
  dbname = input('Please enter the name of database : ')
  db = mysql.connector.connect(
  host = '127.0.0.1',
  user = 'root',
  password = ''
  )
  
  
  cursor = db.cursor()
  cursor.execute("CREATE DATABASE IF NOT EXISTS %s" %dbname)
  cursor.execute("CREATE TABLE IF NOT EXISTS %s (email varchar(30) pwd varchar(20))" %dbname)
  
  db.close()
  </code></pre>