从命令行运行Sqlite3脚本

我正在编写一个 shell脚本来scp一个项目,其中一部分涉及在我的数据库中传输一些重要的表.

我将以下文件存储在sqlTableTransfer文件中:

.o MyTable1.sql;
.dump MyTable1;

.o MyTable2.sql;
.dump MyTable2;

.o MyTable3.sql;
.dump MyTable3;

并抓住机会

$sqlite3 sqlTableTransfer

但这只是打开了sqlite3 shell.从命令行运行这样的脚本的正确方法是什么?

您为sqlite3程序提供的参数是数据库文件名.

要从文件执行命令,必须将输入重定向到该文件

$sqlite3 mydatabase.db < sqlTableTransfer

或告诉它从该文件中读取:

$sqlite3 mydatabase.db ".read sqlTableTransfer"

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能