create table table_a
(
id int auto_increment not null,
name varchar(100) unique,
create_date datetime,
primary key pk_id(id),
index idx_create_date(create_date)
);
insert into table_a(name,create_date) values ('aaaaaa',now());
insert into table_a(name,create_date) values ('bbbbbb',now());
create table table_b
(
id int auto_increment not null,
name varchar(100) unique,
create_date datetime,
primary key pk_id(id),
index idx_create_date(create_date)
);
insert into table_b(name,create_date) values ('aaaaaa',now());
insert into table_b(name,create_date) values ('bbbbbb',now());
执行的时候会提示一个警告,但是不影响最终的结果
mysqldump: [Warning] Using a password on the command line interface can be insecure.
导出建表语句会根据表的数据情况编号自增列,这是mysqldump的问题而不是导出的问题,如果有必要可以需求做相应的修改
去掉mysqldump导出表结构中备注信息
import os
filepath = "D:\\mysqlscript"
# 切换到新建的文件夹中
os.chdir(filepath)
pathDir = os.listdir(filepath)
for file in pathDir:
lines = open(file, "r")
content = "use ***;"
content = content + "\n"
for line in lines:
print(line)
if not (str(line).startswith("--") or str(line).startswith("/*") ):
if(line!="\n" and str(line).startswith(") ENGINE")):
content = content +"\n"+ ")"
else:
content = content + line
#将提炼后的内容重新写入文件
print(content)
fp = open(file, 'w')
fp.write(content)
fp.close()