commands.sh

usql

all

Universal CLI interface for SQL databases.

More info →

Options (2)

-f, --fileboolean

Execute commands from a file

Example: usql {{[-f|--file]}} {{path/to/query.sql}}
-c, --commandboolean

Execute a specific SQL command

Example: usql {{[-c|--command]}} "{{sql_command}}"

Examples (7)

Connect to a specific database

usql sqlserver|mysql|postgres|sqlite3|...://username:password@host:port/database_name

Execute commands from a file

usql [-f|--file] path/to/query.sql

Execute a specific SQL command

usql [-c|--command] "sql_command"

[Interactive] Run an SQL command in the `usql` prompt

[Interactive] Display the database schema

\d

[Interactive] Export query results to a specific file

\g path/to/file_with_results

[Interactive] Import data from a CSV file into a specific table

\copy path/to/data.csv table_name
made by @shridhargupta | data from tldr-pages