sql
sql - execute SQL queries and scripts in dbvr.
Synopsis¶
dbvr sql [-hV]
[-format=<outputFormat> | --output-format=<outputFormat>]
[-in=<inputFile> | -input-file=<inputFile>]
[-l=<limit> | --limit=<limit>]
[-op=<outputFormatParameters> | --output-format-parameters=<outputFormatParameters>]
[-out=<outputFile> | -output-file=<outputFile>]
[-p=<dbPassword> | --password=<dbPassword>]
[--project=<projectIdOrName>]
[-token=<accessToken> | --access-token=<accessToken>]
[-u=<dbUser> | --user=<dbUser>]
[-auth=<authParams> | --auth-property=<authParams>]...
[-ext=<providerParams> | --extended-property=<providerParams>]...
[-prop=<connectionParams> | --property=<connectionParams>]...
[[-net=<handlerParams> | --network-handler-param=<handlerParams>]...
[-net-save-pwd=<savePassword> | --network-handler-save-password=<savePassword>]]
(-ds=<existDataSourceIdOrName> | --datasource=<existDataSourceIdOrName> |
-con=<connectionSpec> | -connect=<connectionSpec> | -ds-spec=<connectionSpec> | --datasource-specification=<connectionSpec> |
[--driver=<driver>
[[--host=<host>]
[--database=<dbName>]
[--server=<server>]
[--url=<url>]
[--auth-model=<authModel>]
[--port=<port>]
[--folder=<folder>]
[--name=<dataSourceName>]
[--save-password=<savePassword>]]])
[<query>]
Tip
You can also use global options with this command.
Tip
SQL execution in dbvr follows the same engine and configuration model as in DBeaver. For UI-based query execution, result export, and execution settings, see SQL execution.
Description¶
Execute a SQL query or script.
You can connect in three ways:
- use an existing datasource with
-dsor--datasource - provide a full connection specification with
-con,-ds-spec,-connector--datasource-specification - define a connection inline using
--driverand connection options
Required argument¶
<query>
SQL statement to execute.
If specified, it must be the last argument in the command.
If omitted, SQL is read from standard input or from -in/-input-file.
Connection options¶
--datasource¶
Use an existing datasource by ID or name.
Use datasource list to see available datasources.
--datasource-specification¶
Provide a full datasource specification string. The specification is a list of key=value pairs separated by |.
Example
--driver¶
Use this option when you want to define a connection inline instead of using an existing datasource.
When --driver is specified, you define the connection inline. Connection
properties work the same way as in datasource create.
--host--port--database--server--url--auth-model-u, --user-p, --password--save-password--folder--name--project
Example
Authentication options¶
--auth-property¶
Add a driver-specific authentication parameter in key=value format. May be specified multiple times.
Example
--user¶
Set the database username used for authentication.
--password¶
Set the database password.
Network options¶
--network-handler-param¶
Configure a network handler parameter in key=value format. Used for SSH tunnels, proxies, or other network
configurations. May be specified multiple times.
Parameter names must match the properties defined by the selected network handler. Use dbvr network-handlers to see available handler IDs and supported parameters.
Example (PostgreSQL via SSH tunnel)
Info
Use network-handlers to see supported handlers and parameters.
--network-handler-save-password¶
Control whether passwords defined in network handlers - such as SSH tunnels or proxy configurations - are stored in the
workspace configuration. Accepts a boolean value. Default: true.
Driver and provider parameters¶
--property¶
Add a driver connection property in key=value format. Passed directly to the JDBC driver for this execution. May be
specified multiple times.
Example (JDBC driver property)
--extended-property¶
Add a driver-specific parameter in key=value format. May be specified multiple times.
Used for additional driver properties that are not part of the authentication model.
Example (Snowflake warehouse)
Input and output options¶
-input-file¶
Read SQL from a file instead of passing a query argument.
--output-format¶
Write the execution result in a specific format.
Supported formats:
csvtxtjsonxmlhtmlmd(markdown)sqlphp(source)parquetxlsx
Default: csv.
--output-format-parameters¶
Exporter options as a list of properties. Comma and space are delimiters.
Example
-output-file¶
Write the execution result to a file.
Example
Tip
Export formats and options use the same exporters as in DBeaver. For details on supported formats and configuration, see Data export.
Tip
You can write results not only to local files, but also to cloud storage if it’s configured. For example:
Supported cloud schemes depend on your environment configuration, for example s3:// or gs://. Credentials must be
configured externally, for example using AWS CLI, gcloud CLI, or environment variables.
--limit¶
Limit the number of fetched rows and optionally set an offset. Default: 1000.
Example
Examples¶
Run a query using an existing datasource:
Run a script from a file:
Run with inline connection parameters:
dbvr sql \
--driver=postgres-jdbc \
--host=localhost \
--database=testdb \
-u=admin \
-p=password \
"select * from users;"
Export results to CSV: