一,在sqlite数据库的shell 操作:
1,导出数据库某个表:
.output table_name.sql
.dump table_name
如果是导出全部表:
直接 .dump
2,导入数据表:
.read table_name.sql
二,python 脚本:
1,导出表:
cmd = "sqlite3 db.sqlite3 '.dump table_name' > table_name.sql"
os.system(cmd)
2,导入表:
cmd = "sqlite3
db.sqlite3 '.read table_name.sql' "
os.system(cmd)
本文介绍如何使用SQLite数据库的shell命令进行表的导出与导入操作,并提供了相应的Python脚本实现方式,包括通过命令行工具输出指定表的数据到SQL文件及读取SQL文件恢复数据。
582

被折叠的 条评论
为什么被折叠?



