1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #! /bin/sh
QUERY=$1
TABLE=$2
echo -e "Here is your statement:\n"
CMD="BEGIN;\n"
CMD=$CMD`echo '.tables' | sqlite3 $TABLE | tr ' ' '\n' | grep $QUERY | sed 's/^/DROP TABLE /g' | sed 's/$/;/g'`
CMD=$CMD"\nCOMMIT;"
echo -e "$CMD\n"
echo -n "Do you want to commit this statement? (Y/N) "
read -e ANSWER
if test "$ANSWER" = "Y"; then
echo -e "$CMD" | sqlite3 $TABLE
echo "Done!"
else
echo "Nothing changed, have a good day."
fi
exit
|
More like this
- oneliner to delete SQLite tables by kifkif 3 years, 7 months ago
- fast table flush without raw SQL by dsblank 3 years, 5 months ago
- Drop all tables in MySQL database by mpasternacki 3 years, 3 months ago
- Add special field lookups to the Admin list_filter display by whiteinge 5 years, 3 months ago
- CompressedTextField for Django 1.4+ by devhulu 3 months, 1 week ago
Comments