|
|
|
|
|
by dashezup
1807 days ago
|
|
True, I don't see the benefits of writing it in bash/shell script in this case. Plus you can get proper syntax highlighting for SQL in your text editor for ".sql" file. sqlite3 database.db <query.sql
Some other DBMS have similar things, for MariadDB you could write it in a ".sql" file as well, setting variables and use it so that you can write a generic sql file. (seems you can't use the variable thing with sqlite3) MariaDB> SET @username='UserName@localhost';
MariaDB> SET @hostname='localhost';
MariaDB> SOURCE create-user.sql;
Such things is usually cleaner/simpler than writing in bash. |
|
You could also read the contents of the query file into a shell parameter with the `read` builtin.