init
This commit is contained in:
23
create_db.py
Normal file
23
create_db.py
Normal file
@ -0,0 +1,23 @@
|
||||
import mysql.connector
|
||||
|
||||
try:
|
||||
# Connect to MySQL server
|
||||
conn = mysql.connector.connect(
|
||||
host='127.0.0.1',
|
||||
user='root',
|
||||
password='123456',
|
||||
port=3306
|
||||
)
|
||||
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Create database
|
||||
cursor.execute("CREATE DATABASE IF NOT EXISTS qiandao CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci")
|
||||
|
||||
print("Database 'qiandao' created successfully!")
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
Reference in New Issue
Block a user