Use "here document" statements to build complex script files with embedded sql statements via the sqlite/sqlite3 utility.
Note that being in a bash script means that you can expand $-variables inside the sql code directly. This is,however,not advised unless you can be sure that only trusted,competent people will run your code. Otherwise you'll be facing sql injection attacks.