blob: ce99c793232750abbc26b902a53668ac7d6b2110 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/usr/bin/env bash
set -e
# @describe Execute the sql code.
# @option --code! The code to execute.
# @env USQL_DSN! The database url, e.g. pgsql://user:pass@host/dbname
# @meta require-tools usql
main() {
if ! grep -qi '^select' <<<"$argc_code"; then
if [ -t 1 ]; then
read -r -p "Are you sure you want to continue? [Y/n] " ans
if [[ "$ans" == "N" || "$ans" == "n" ]]; then
echo "Aborted!"
exit 1
fi
fi
fi
usql -c "$argc_code" "$USQL_DSN" >> "$LLM_OUTPUT"
}
eval "$(argc --argc-eval "$0" "$@")"
|