加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Making SQLITE/SQLITE3 executable scripts

发布时间:2020-12-12 20:36:57 所属栏目:百科 来源:网络整理
导读: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 myt
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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读