Can you write sql commands using a .bat file?

batch-file, command-line, sql, sqlite

Solution

You can give a command as parameter to the `sqlite3` tool:

sqlite3 mydatabasefile ".read file_name.sql"

Problem

I'm designing a process to create a list of fuzzy duplicates for my colleagues. I have automated most of the process and have used a .bat file to open sqlite. However, I can now find no other way to read the code other than to manually type: ``` .read file_name.sql ``` Into command prompt. Is there a way I could type open and read the file from notepad with the commands prewritten, like a .bat file. For example: ``` cd sqlite -- enter directory with sqlite3 inside of it. DOS command sqlite3 --to open the sqlite3 application DOS command .read file_name.sql -- SQLite command ``` Thanks in advance, sorry if the question is trivial.

Original source