Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RodrigoMattosoSilveira/4664d600707ec41947e083e1e24b20a9 to your computer and use it in GitHub Desktop.
Save RodrigoMattosoSilveira/4664d600707ec41947e083e1e24b20a9 to your computer and use it in GitHub Desktop.
Execute SQL statements from a file
Execute SQL statements from a file
Suppose we have a file named commands.txtin the c:\sqlite\folder with the following content:
```
SELECT albumid, title
FROM albums
ORDER BY title
LIMIT 10;
Code language: Shell Session (shell)
```
To execute the SQL statements in the commands.txtfile, you use the .read FILENAMEcommand as follows:
```
sqlite> .mode column
sqlite> .header on
sqlite> .read c:/sqlite/commands.txt
AlbumId Title
---------- ----------------------
156 ...And Justice For All
257 20th Century Masters -
296 A Copland Celebration,
94 A Matter of Life and D
95 A Real Dead One
96 A Real Live One
285 A Soprano Inspired
139 A TempestadeTempestade
203 A-Sides
160 Ace Of Spades
Code language: Shell Session (shell)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment