Making SQLITE/SQLITE3 executable scripts

前端之家收集整理的这篇文章主要介绍了Making SQLITE/SQLITE3 executable scripts前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Use "here document" statements to build complex script files with embedded sql statements via the sqlite/sqlite3 utility.

#! /usr/bin/env bash

# execute some bash scripting commands here

sqlite3 mydatabase <<sql_ENTRY_TAG_1
SELECT * 
  FROM mytable 
  WHERE somecondition='somevalue';
sql_ENTRY_TAG_1

# execute other bash scripting commands here

sql_ENTRY_TAG_2
SELECT *
  FROM myothertable
  WHERE someothercondition='someothervalue';
sql_ENTRY_TAG_2

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. 原文链接:https://www.f2er.com/sqlite/202278.html

猜你在找的Sqlite相关文章