Files
SIC/code/dataintolib/clear_datelib.sh
2023-02-28 09:33:09 +08:00

51 lines
1.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
LIDADDR="../datalib/fileinfo.db"
echo " 选择需要删除的数据类型"
echo "================================================================="
echo " 1 删除指定产品 2 删除指定安装包 3 删除指定文件 4 清除所有文件 5 清除所有 "
read stat
case ${stat:0:1} in
1)
echo "请输入产品id"
read product_id
sqlite3 $LIDADDR "delete from product where product_id = $product_id"
for id in `sqlite3 $LIDADDR "select pkg_id from product_and_pkg where product_id = $product_id"`
do
sqlite3 $LIDADDR "delete from file where pkg_id = $id"
sqlite3 $LIDADDR "delete from pkg where pkg_id = $id"
sqlite3 $LIDADDR "delete from product_and_pkg where product_id = $product_id"
done
;;
2)
echo "请输入安装包id"
read pkg_id
sqlite3 $LIDADDR "delete from file where pkg_id = $pkg_id"
sqlite3 $LIDADDR "delete from pkg where pkg_id = $pkg_id"
sqlite3 $LIDADDR "delete from product_and_pkg where pkg_id = $pkg_id"
;;
3)
echo "请输入文件名"
read file_id
sqlite3 $LIDADDR "delete from file where file_id = $file_id"
;;
4)
sqlite3 $LIDADDR "delete from file"
;;
5)
sqlite3 $LIDADDR "delete from file"
sqlite3 $LIDADDR "delete from pkg"
sqlite3 $LIDADDR "delete from product_and_pkg"
sqlite3 $LIDADDR "delete from product"
;;
*)
echo "输入错误请输入1、2、3、4"
;;
esac