「Python」MySQLでデータベースを作成する
書式
mysql.connector.connect(host=xxx,user=xxx,password=xxx
使用例
import mysql.connector
#mysqlに接続 ユーザー名 パスワード ホスト名
cfdb = mysql.connector.connect(
host="localhost",
user="root",
password="2345"
)
cftcursor = cfdb.cursor()
#データベースの作成
cftcursor.execute("CREATE DATABASE testdb")