You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
555 B

import mysql.connector
# 连接到 MySQL 数据库
conn = mysql.connector.connect(
host="localhost", # 数据库主机地址
user="root", # 数据库用户名
password="123123", # 数据库密码
database='shop'
)
# 创建一个游标对象
cursor = conn.cursor()
# 读取 SQL 文件内容
with open('igs_stations.sql', 'r') as file:
sql_statements = file.read()
# 执行 SQL 文件中的查询语句
for result in cursor.execute(sql_statements, multi=True):
pass
# 提交更改
conn.commit()
# 关闭连接
conn.close()