使 SQLite3 命令文件可执行
Make a SQLite3 command file executable
我有一个 SQLite3 命令文件。例如,
.print "This is running in SQLite3!"
我想要
的行为
sqlite3 < commands.sql
当我 运行 在 OSX 上进行以下操作时:
./commands.sql
这是我目前的解决方案:
#!/usr/bin/env sqlite3 -init
.print "This is running in SQLite3!"
这有效,但它也会打印一些不需要的行:
-- Loading resources from ./process_errors.sql
Error: near line 1: unrecognized token: "#"
This is running in SQLite3!
应该可以
#!/usr/bin/env bash
tail -n +4 "[=10=]" | sqlite3
exit $?
-- sql commands
select * from some_table
我有一个 SQLite3 命令文件。例如,
.print "This is running in SQLite3!"
我想要
的行为sqlite3 < commands.sql
当我 运行 在 OSX 上进行以下操作时:
./commands.sql
这是我目前的解决方案:
#!/usr/bin/env sqlite3 -init
.print "This is running in SQLite3!"
这有效,但它也会打印一些不需要的行:
-- Loading resources from ./process_errors.sql
Error: near line 1: unrecognized token: "#"
This is running in SQLite3!
应该可以
#!/usr/bin/env bash
tail -n +4 "[=10=]" | sqlite3
exit $?
-- sql commands
select * from some_table