Reputation: 773
For years (at least since 2004) I've developed databases using SQLite and running the scripts under the command prompt, like this:
sqlite3 mytest.db < mytest.sql > mytest.txt
This runs the script contained in mytest.sql
and outputs to mytest.txt
, and then returns back to the OS prompt. I can use a quick edit, test, and review cycle.
However, when I try the same with PowerShell, like this:
.\sqlite3 mytest.db -init mytest.sql > mytest.txt
I get stuck and have to Ctrl + C to escape back to the prompt. Otherwise, it's just the same as in the command prompt.
I've tried the following in my SQL script:
.exit
[SQLite dot command].system Exit
.system Exit-PSSession
.system Exit-PSHostProcess
| Exit-PSHostProcess
); Exit-PSHostProcess
)But nothing seems to work. Doing Ctrl + C isn't a big deal, but it's aggravating to have to do it. Is there a way to return to the PowerShell prompt after running the SQLite script?
Upvotes: 2
Views: 606
Reputation: 1197
The input redirection <
is reserved in powershell so it won't work. You have to do something like this:
gc .\mytest.sql | sqlite3.exe mytest.db > mytest.txt
After running the commands in \mytest.sql
it will exit automatically
Upvotes: 0
Reputation: 11
I'm replying to a very old post, but well, I have the same problem and I just found the solution.
Maybe this will be useful for someone else :
sqlite3 .\mytest.db -init .\mytest.sql -batch .exit
Upvotes: 1