snow helpers import-snowsql-connections

从 SnowSQL 配置导入现有连接。

语法

snow helpers import-snowsql-connections
  --snowsql-config-file <custom_snowsql_config_files>
  --default-connection-name <default_cli_connection_name>
  --format <format>
  --verbose
  --debug
  --silent
  --enhanced-exit-codes
  --decimal-precision <decimal_precision>

实参

选项

--snowsql-config-file FILE

指定自定义 SnowSQL 配置的文件路径。该选项可以多次用于指定多个文件。

--default-connection-name TEXT

指定 Snowflake CLI 中为从 SnowSQL 导入的默认连接提供的名称。默认值:default。

--format [TABLE%JSON%JSON_EXT|CSV]

指定输出格式。默认:TABLE。

--verbose, -v

Displays log entries for log levels info and higher. Default: False.

--debug

Displays log entries for log levels debug and higher; debug logs contain additional information. Default: False.

--silent

关闭到控制台的中间输出。默认值:False。

--enhanced-exit-codes

根据错误类型区分退出错误代码。默认值:False。

--decimal-precision INTEGER

Number of decimal places to display for decimal values. Uses Python’s default precision if not specified. [env var: SNOWFLAKE_DECIMAL_PRECISION].

--help

Displays the help text for this command.

使用说明

The snow helpers import-snowsql-connections command imports existing connection definitions from SnowSQL into your config.toml configuration file.

By default, the command reads the SnowSQL configuration files in the order described in the Configuring SnowSQL topic. If more than one of these configurations define the same connection, this command overwrites the previously imported connection definition with the most recent one. To illustrate, assume the same [connections.example] connection is defined with different parameters in the following locations:

Location of the configuration fileConnection definition
/etc/snowsql.cnf
[connections]

[connections.example]
username=user1
<HOME_DIR>/.snowsql/config
[connections]

[connections.example]
username=user2
password=<my-pwd>

After you run the command, your Snowflake CLI config.toml file contains the following [connections.example] definition (from the file with the higher precedence):

[connections]

[connections.example]
username=user2
password=<my-pwd>

You can use the --snowsql-config-file option to override this default behavior and import from one or more specific SnowSQL configuration files instead.

The snow helpers import-snowsql-connections command also imports the default connection from SnowSQL, which is not a named connection. It is defined directly in the [connections] section of the configuration file. Because Snowflake CLI requires all connections to be named, the command defines a connection named [default]. If you want to use another name for the default connection, you can specify it with the --default-connection-name option.

If a SnowSQL connection matches the name of an existing Snowflake CLI connection, the command prompt asks whether you want to overwrite the existing connection or skip importing that SnowSQL connection.

示例

以下示例从标准配置文件位置导入 SnowSQL 连接:

snow helpers import-snowsql-connections

As the command processes the SnowSQL configuration files, it shows the progress and prompts for confirmation when a connection with the same name is already defined in the Snowflake CLI config.toml file.

SnowSQL config file [/etc/snowsql.cnf] does not exist. Skipping.
SnowSQL config file [/etc/snowflake/snowsql.cnf] does not exist. Skipping.
SnowSQL config file [/usr/local/etc/snowsql.cnf] does not exist. Skipping.
Trying to read connections from [/Users/<user>/.snowsql.cnf].
Reading SnowSQL's connection configuration [connections.connection1] from [/Users/<user>/.snowsql.cnf]
Trying to read connections from [/Users/<user>/.snowsql/config].
Reading SnowSQL's default connection configuration from [/Users/<user>/.snowsql/config]
Reading SnowSQL's connection configuration [connections.connection1] from [/Users/<user>/.snowsql/config]
Reading SnowSQL's connection configuration [connections.connection2] from [/Users/<user>/.snowsql/config]
Connection 'connection1' already exists in Snowflake CLI, do you want to use SnowSQL definition and override existing connection in Snowflake CLI? [y/N]: Y
Connection 'connection2' already exists in Snowflake CLI, do you want to use SnowSQL definition and override existing connection in Snowflake CLI? [y/N]: n
Connection 'default' already exists in Snowflake CLI, do you want to use SnowSQL definition and override existing connection in Snowflake CLI? [y/N]: n
Saving [connection1] connection in Snowflake CLI's config.
Connections successfully imported from SnowSQL to Snowflake CLI.