Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting a .sql file to .db file in Windows

I have been trying to learn SQL by doing the exercises on the Learn SQL the Hard Way site. I have made a file in folder on my desktop called ex1.sql, and I have put all of the sqlite3 stuff in PATH. However, I am using Windows Powershell and I cannot perform the command:

sqlite3 ex1.db < ex1.sql

I am getting this error in the Powershell terminal:

At line:1 char:16
+ sqlite3 ex1.db < ex1.sql
+                ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupport

So, I guess '<' can only be used to redirect on Unix OS. I have tried to find an equivalent command in powershell, but I have not found one yet. If anyone has had this problem or knows how to redirect .sql files to .db, then that would be great.

like image 726
Jon Mueller Avatar asked Dec 09 '25 23:12

Jon Mueller


1 Answers

You could try:

get-content ext1.sql | sqllite3 ext1.db

The article has a nice discussion of legacy redirection issues in Powershell and various workarounds:

http://blogs.technet.com/b/heyscriptingguy/archive/2011/07/16/working-around-legacy-redirection-issues-with-powershell.aspx

like image 193
Chad Miller Avatar answered Dec 12 '25 16:12

Chad Miller