Access the MSSQL Database

Installation

docker exec -i bitwarden-mssql sh <<"EOF"
apt update \
  && apt install -y mssql-cli libffi-dev libssl-dev python3-pip \
  && pip3 install --system "pymssql<3.0" mssqlcli
EOF

Access

mssql-cli

The official Microsoft CLI.

read BW_MSSQL_PW < <( sed -rn '/^SA_PASSWORD=/{s/^[^=]+=//;p}' < bwdata/env/mssql.override.env )

docker exec -it bitwarden-mssql mssql-cli -U sa -P "${BW_MSSQL_PW}"

mssqlcli

A third party CLI with more / different features.

read BW_MSSQL_PW < <( sed -rn '/^SA_PASSWORD=/{s/^[^=]+=//;p}' < bwdata/env/mssql.override.env )

docker exec -i bitwarden-mssql sh -c 'mkdir -p ~/.config && cat > ~/.config/mssqlcli.yml' <<EOF
username: sa
password: ${BW_MSSQL_PW}
server: localhost
EOF

docker cp ${PATH_TO_SQL} bitwarden-mssql:/tmp/query.sql
docker exec -i -e LC_ALL=C.UTF-8 -e LANG=C.UTF-8 bitwarden-mssql mssqlcli -o json query /tmp/query.sql

Troubleshooting