Skip to content

datasource create

Synopsis

dbvr datasource create [-hV] --driver=<driver>
                             [-p=<dbPassword>] [--project=<projectIdOrName>]
                             [-u=<dbUser>]
                             [-auth=<authParams> | --auth-property=<authParams>]...
                             [-ext=<providerParams> | --extended-property=<providerParams>]...
                             [-prop=<connectionParams> | --property=<connectionParams>]...
                             [[--host=<host>]
                              [--database=<dbName>]
                              [--server=<server>]
                              [--url=<url>]
                              [--auth-model=<authModel>]
                              [--port=<port>]
                              [--folder=<folder>]
                              [--name=<dataSourceName>]
                              [--save-password=<savePassword>]]
                             [[-net=<handlerParams> | --network-handler-param=<handlerParams>]...
                              [-net-save-pwd=<savePassword> | --network-handler-save-password=<savePassword>]]

Tip

You can also use global options with this command.

Tip

You can create a connection in the DBeaver UI and then use it in dbvr. Both tools use the same workspace format. For step-by-step instructions, see Create connection.

Description

Create a new datasource.

The datasource definition is written to the active workspace configuration, making it available for other dbvr commands such as sql, datasource list, or datasource update.

Required option

--driver=<driver>

Important

The --driver value must match a registered driver. Use driver list to see available Driver IDs.

Options

--password

-p, --password=<dbPassword>

Set the database password.

--project

--project=<projectIdOrName>

Store the datasource in the specified project. If not set, the datasource is created in the General project.

Tip

Run project list to see available projects.

--user

-u, --user=<dbUser>

Set the database username used for authentication.

--auth-property

-auth, --auth-property=<authParams>

Add a driver-specific authentication parameter in key=value format. May be specified multiple times.

Example

dbvr datasource create \
  --driver=postgres-jdbc \
  --name="PostgreSQL local" \
  --host=localhost \
  --database=testdb \
  --auth-model=ssl \
  --auth-property=ssl=true \
  --auth-property=sslmode=require

--property

-prop, --property=<connectionParams>

Add a driver connection property in key=value format. Passed directly to the JDBC driver for this connection. May be specified multiple times.

Use it to override or set driver-specific settings for the current datasource instead of relying on global driver defaults.

Example

dbvr datasource create \
  --driver=postgres-jdbc \
  --name="PostgreSQL local" \
  --host=localhost \
  --database=testdb \
  --user=app \
  --password=secret \
  --property=ssl=true \
  --property=applicationName=dbvr-cli

--extended-property

-ext, --extended-property=<providerParams>

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. These parameters may affect authentication or other driver-specific behavior.

Example (Snowflake warehouse)

dbvr datasource create \
  --driver=snowflake-jdbc \
  --name="Snowflake local" \
  --host=account.snowflakecomputing.com \
  --database=TESTDB \
  --user=app \
  --password=secret \
  --extended-property=warehouse=COMPUTE_WH

--host

--host=<host>

Set the database host name or IP address.

Info

Ignored if --url is specified.

--database

--database=<dbName>

Set the database name. For some drivers, this may represent a schema, service name, or logical database.

Info

Ignored if --url is specified.

--server

--server=<server>

Set the logical server name required by certain drivers.

Info

Ignored if --url is specified.

--url

--url=<url>

Provide the full JDBC connection URL.

Note

When specified, it overrides --host, --port, --database, and --server.

--auth-model

--auth-model=<authModel>

Specify the authentication model supported by the selected driver.

Authentication models define how credentials are provided - for example username/password, Kerberos, IAM, OAuth, or key-based authentication.

Tip

Run auth-models to see all available authentication models and their parameters. Not every model is supported by every driver. Use only the models applicable to your selected driver.

--port

--port=<port>

Set the database port number. Must be a valid integer. Ignored if --url is specified.

--folder

--folder=<folder>

Place the datasource into a folder within the project.

--name

--name=<dataSourceName>

Set the name of the datasource as it appears in the workspace.

--save-password

--save-password=<savePassword>

Control whether the database password is stored in the workspace configuration. Accepts a boolean value.

--network-handler-param

-net, --network-handler-param=<handlerParams>

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

dbvr datasource create \
  --driver=postgres-jdbc \
  --name="PostgreSQL via SSH" \
  --host=remote-db \
  --database=testdb \
  --user=app \
  --password=secret \
  -net=ssh.host=example.com \
  -net=ssh.port=22 \
  -net=ssh.user=sshuser \
  -net=ssh.authType=password \
  -net=ssh.password=sshpass

Each -net defines one property of the network handler configuration.

Tip

Network handler configuration in dbvr follows the same model as in DBeaver. For SSH tunnel setup details, see SSH configuration.

--network-handler-save-password

-net-save-pwd, --network-handler-save-password=<savePassword>

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.

Examples

Create a basic PostgreSQL datasource:

dbvr datasource create \
  --driver=postgres-jdbc \
  --name=pg-local \
  --host=localhost \
  --port=5432 \
  --database=testdb \
  --user=app \
  --password=secret

Create a datasource in a specific project and folder:

dbvr datasource create \
  --driver=postgres-jdbc \
  --name=pg-prod \
  --project=Prod \
  --folder=Finance \
  --host=prod-db \
  --database=maindb \
  --user=app \
  --password=secret

Create a datasource using a full JDBC URL:

dbvr datasource create \
  --driver=postgres-jdbc \
  --name=pg-url \
  --url=jdbc:postgresql://localhost:5432/testdb \
  --user=app \
  --password=secret

Create a datasource with an SSH tunnel:

dbvr datasource create \
  --driver=postgres-jdbc \
  --name=pg-ssh \
  --host=remote-db \
  --database=testdb \
  --user=app \
  --password=secret \
  -net=ssh.host=example.com \
  -net=ssh.port=22 \
  -net=ssh.user=sshuser \
  -net=ssh.authType=password \
  -net=ssh.password=sshpass