Skip to content

Instantly share code, notes, and snippets.

@andrewpetrochenkov
Last active August 4, 2024 10:13
Show Gist options
  • Save andrewpetrochenkov/de4a252a0e7b0329b9f222f568972f9c to your computer and use it in GitHub Desktop.
Save andrewpetrochenkov/de4a252a0e7b0329b9f222f568972f9c to your computer and use it in GitHub Desktop.
sqlite database locked
#!/usr/bin/env bash
# https://stackoverflow.com/questions/2740806/python-sqlite-database-is-locked
function sqlite3() {
executable="$(which sqlite3)" || exit
out="$("$executable" "$@" 2>&1)" && echo "$out" && return || {
[[ "$out" == *"locked"* ]] && exit; echo "$out" 1>&2 && exit 1
}
}
integrity_check="$(sqlite3 "$db" "pragma integrity_check;" 2> /dev/null)" || exit
[[ "$integrity_check" != "ok" ]] && echo "SKIP: integrity_check $integrity_check" && exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment