Understand usql Release Builds
mainusql are compiled using the most build tag and include additional SQLite3 build tags. This ensures that the binaries come pre-equipped with support for a wide variety of database drivers.repository·main·Indexed 27 days ago
https://github.com/xo/usqlA universal command-line interface for interacting with a wide variety of SQL and NoSQL databases, inspired by PostgreSQL's psql. It features support for multiple database drivers (including PostgreSQL, MySQL, SQLite3, Microsoft SQL Server, Oracle, and ODBC), syntax highlighting, and the ability to copy data between different databases using the \copy command.
usql are compiled using the most build tag and include additional SQLite3 build tags. This ensures that the binaries come pre-equipped with support for a wide variety of database drivers.On Arch Linux, you can install usql using an AUR helper like yay, or by manually building the package using makepkg from the cloned AUR repository.
# install usql with most drivers
$ yay -S usql
# build and install using makepkg
$ git clone https://aur.archlinux.org/usql.git && cd usql
$ makepkg -siTo avoid providing passwords in connection strings, you can use a .usqlpass file in your $HOME directory.
Format:
protocol:host:port:dbname:user:pass
Example:
postgres:*:*:*:booktest:booktest
Security Note: Ensure the file is not readable by other users:
chmod 0600 ~/.usqlpass
usql manually, download the appropriate release for your platform from the official GitHub releases page. Extract the usql or usql.exe file from the .tar.bz2 or .zip archive and move the executable to a directory included in your $PATH (Linux/macOS) or %PATH% (Windows).usql connects to databases using a Data Source Name (DSN) or a connection URL. You can pass the DSN as a command-line argument or use the \c command within the interactive interpreter.
driver+transport://user:pass@host/dbname?opt1=a&opt2=b/path/to/file (used for local files like SQLite or directory-based databases like PostgreSQL)config.yaml or via \cset.Most drivers have two-character short aliases:
pg for postgresmy for mysqlms for sqlserveror for oraclesq for sqlite3# connect to a postgres database
$ usql postgres://booktest@localhost/booktest
# connect to an oracle database
$ usql oracle://user:pass@host/oracle.sid
# connect to a postgres database and run the commands contained in script.sql
$ usql pg://localhost/ -f script.sqlTo install usql on Windows using Scoop, ensure your execution policy allows remote scripts, install Scoop if necessary, and then run the install command.
# Optional: Needed to run a remote script the first time
> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
# install scoop if not already installed
> irm get.scoop.sh | iex
# install usql with scoop
> scoop install usqlTo test the DB2 environment, run the DB2 container using the provided podman script and then execute the validation script to ensure the driver and configuration are working correctly.
Run the container:
$ ../podman-run.sh db2 -uVerify the installation:
$ ./db2cli-validate.sh$ ../podman-run.sh db2 -u
$ ./db2cli-validate.sh\connect (or \c) command inside the usql interactive session. Use the appropriate scheme or one of its aliases.Use the official docker.io/usql/usql image to run usql in a container. This is useful for connecting to databases without local installation or for running specific versions.
# run interactive shell and mount the $PWD/data directory as a volume for use
# within the container
$ docker run --rm -it --volume $(pwd)/data:/data docker.io/usql/usql:latest sqlite3://data/test.db
# connect to local postgres instance (assuming postgres is running on host network)
$ docker run --rm --network host -it docker.io/usql/usql:latest postgres://postgres:P4ssw0rd@localhost
# run specific usql version
$ docker run --rm -it docker.io/usql/usql:0.19.3Before running the Couchbase Docker image, create a persistent volume for data storage using Podman:
$ podman volume create couchbase-dataYou can install usql using go install. By default, only the base drivers (PostgreSQL, MySQL, SQLite3, Microsoft SQL Server, Oracle, CSVQ) are included. To include a wider range of drivers, use the most build tag.
# install latest usql version with base drivers
$ go install github.com/xo/usql@latest
# install usql with most drivers
$ go install -tags most github.com/xo/usql@latestOnce the Couchbase Docker image is running, you can access the management interface by navigating to the following URL in your browser:
http://127.0.0.1:8091/ui/index.html
You must manually configure the database through this interface.