2024-02-19 14:34:37 +00:00
|
|
|
# usql
|
|
|
|
|
|
|
|
> Universal CLI interface for SQL databases.
|
|
|
|
> More information: <https://github.com/xo/usql>.
|
|
|
|
|
|
|
|
- Connect to a specific database:
|
|
|
|
|
|
|
|
`usql {{sqlserver|mysql|postgres|sqlite3|...}}://{{username}}:{{password}}@{{host}}:{{port}}/{{database_name}}`
|
|
|
|
|
|
|
|
- Execute commands from a file:
|
|
|
|
|
|
|
|
`usql --file={{path/to/query.sql}}`
|
|
|
|
|
|
|
|
- Execute a specific SQL command:
|
|
|
|
|
|
|
|
`usql --command="{{sql_command}}"`
|
|
|
|
|
|
|
|
- Run an SQL command in the `usql` prompt:
|
|
|
|
|
|
|
|
`{{prompt}}=> {{command}}`
|
|
|
|
|
|
|
|
- Display the database schema:
|
|
|
|
|
|
|
|
`{{prompt}}=> \d`
|
|
|
|
|
|
|
|
- Export query results to a specific file:
|
|
|
|
|
2024-06-18 15:02:42 +01:00
|
|
|
`{{prompt}}=> \g {{path/to/file_with_results}}`
|
2024-02-19 14:34:37 +00:00
|
|
|
|
|
|
|
- Import data from a CSV file into a specific table:
|
|
|
|
|
2024-06-18 15:02:42 +01:00
|
|
|
`{{prompt}}=> \copy {{path/to/data.csv}} {{table_name}}`
|