SQLite 中的 .quit 和 .exit 有区别吗?
我正在编写一个 VBScript 脚本来在 SQLite shell 中执行 SQL 查询,并且想知道是否需要使用 .quit 或 .exit。
当我在任务计划程序中设置任务来运行此 VBScript 脚本时,SQLite shell 无法正确退出/退出,因此每次任务计划程序运行时都会创建一个新实例,这会导致 SQL 查询无法执行被处决。当我双击 VBScript 脚本时,它运行良好并且 SQLite shell 正常存在。
我该如何解决这个问题?
脚本:
Dim objShell
Dim main_database_file, main_output_file, main_sqlite_file
Dim TAB, LINE
' Set default values here if necessary
main_database_file = "G:\example\data\reporting\lastmonth"
main_sqlite_file = "G:\example\sqlite-shell.exe"
main_output_file="G:\example\scripts\display-time.csv"
Set objShell = createObject("Wscript.Shell")
sql = "select * from project;"
objShell.Run """"& main_sqlite_file &"""" & """"& main_database_file &""""
WScript.Sleep(500)
objShell.Sendkeys(".separator ,{ENTER}")
objShell.Sendkeys(".headers ON{ENTER}")
objShell.Sendkeys(".output '" & main_output_file &"'{ENTER}")
objShell.Sendkeys(sql & "{ENTER}")
WScript.Sleep(500)
objShell.Sendkeys(".quit{ENTER}")
Set objShell = Nothing
I am writing a VBScript script to execute an SQL query in the SQLite shell and was wondering if I needed to use .quit or .exit.
When I set up a task in the task scheduler to run this VBScript script, the SQLite shell doesn’t exit/quit properly due to which I get a new instance created every time the task scheduler run and this is causes the SQL query to not be executed. When I double click on the VBScript script it runs fine and SQLite shell exists gracefully.
How can I fix this?
The script:
Dim objShell
Dim main_database_file, main_output_file, main_sqlite_file
Dim TAB, LINE
' Set default values here if necessary
main_database_file = "G:\example\data\reporting\lastmonth"
main_sqlite_file = "G:\example\sqlite-shell.exe"
main_output_file="G:\example\scripts\display-time.csv"
Set objShell = createObject("Wscript.Shell")
sql = "select * from project;"
objShell.Run """"& main_sqlite_file &"""" & """"& main_database_file &""""
WScript.Sleep(500)
objShell.Sendkeys(".separator ,{ENTER}")
objShell.Sendkeys(".headers ON{ENTER}")
objShell.Sendkeys(".output '" & main_output_file &"'{ENTER}")
objShell.Sendkeys(sql & "{ENTER}")
WScript.Sleep(500)
objShell.Sendkeys(".quit{ENTER}")
Set objShell = Nothing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,根据 文档,
.quit
和.exit
是“退出这个程序”,所以我不相信,不。Well, according to the documentation, the description of both
.quit
and.exit
is "Exit this program", so I don't believe so, no.我同意杰克的观点,医生说没有区别。
但是,为什么不将命令输入到命令行处理器呢?您可以创建一个包含上述每个步骤的“SQL”文件,然后执行单个运行命令:
类似于(未测试!)
SQL 文件:
然后运行此文件:
不需要任意超时,并且您也许也可以传入参数。
PS:问题可能是在计划任务的上下文中运行的 sendkeys
I would agree with Jack that the doc states no difference.
However, why not pipe your commands in to the Command-Line-Processor? You can create a 'SQL' file containing each of the steps above and then execute the single run command:
Something like (not tested!)
SQL file:
Then run this file as:
There isn't any need for arbitrary timeouts, and you can probably pass in parameters too.
PS: It's probably sendkeys running in the context of a scheduled task that is the problem
我认为唯一的区别是
.quit
在某些 Unix 系统上不起作用。I think the only difference is
.quit
doesn't work on some Unix systems.