简体   繁体   中英

Is there a difference between .quit and .exit in SQLite?

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

好吧,根据文档.quit.exit的描述都是“退出此程序”,所以我不这么认为,不。

我认为唯一的区别是.quit在某些 Unix 系统上不起作用。

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:

.separator ,
.headers on
etc..

Then run this file as:

shell.run "sqlite-clp.exe mydb.db < sqlfile.sql"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM