commit_0603

main
123456789zs 6 months ago
parent 22030ddebb
commit 97c4c848eb

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="sys@localhost" uuid="acb4c168-4ee1-49dd-98cb-95242bb5a1c8">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306/sys</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

Binary file not shown.

@ -1,6 +1,45 @@
import tkinter as tk
from tkinter import messagebox
import pymysql
# 数据库连接配置
host = 'localhost'
user = 'root'
password = '123456'
db = 'sys'
try:
# 尝试连接数据库
conn = pymysql.connect(host=host, user=user, password=password, db=db)
print("数据库连接成功")
# 创建一个Cursor对象
cursor = conn.cursor()
# 定义创建用户表的SQL语句
create_table_sql = """
CREATE TABLE IF NOT EXISTS users (
user_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
)
"""
# 执行SQL语句创建表
cursor.execute(create_table_sql)
print("用户表创建成功")
# 提交事务
conn.commit()
except pymysql.MySQLError as e:
print(f"数据库操作出错: {e}")
finally:
# 关闭Cursor和Connection
if cursor:
cursor.close()
if conn:
conn.close()
class FootSpaManagementSystem:
def __init__(self,order_info=""):

Loading…
Cancel
Save