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
Copy

实参

选项

--snowsql-config-file FILE

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

--default-connection-name TEXT

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

--format [TABLE|JSON]

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

--verbose, -v

显示日志级别 info 及更高级别的日志条目。默认值:False。

--debug

显示日志级别 debug 及更高级别的日志条目;调试日志包含其他信息。默认值:False。

--silent

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

--help

显示此命令的帮助文本。

使用说明

snow helpers import-snowsql-connections 命令将现有连接定义从 SnowSQL 导入到 config.toml 配置文件中。

默认情况下,该命令按照 配置 SnowSQL 主题中所述的顺序读取 SnowSQL 配置文件。如果这些配置中有多个配置定义了相同的连接,则此命令将使用最新的连接定义覆盖以前导入的连接定义。为了说明问题,假设在以下位置使用不同的参数定义了相同的 [connections.example] 连接:

配置文件的位置

连接定义

/etc/snowsql.cnf

[connections]

[connections.example]
username=user1
Copy

<HOME_DIR>/.snowsql/config

[connections]

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

运行该命令后,Snowflake CLI config.toml 文件包含以下 [connections.example] 定义(来自优先级较高的文件):

[connections]

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

您可以使用 --snowsql-config-file 选项替换此默认行为,并从一个或多个特定 SnowSQL 配置文件导入。

snow helpers import-snowsql-connections 命令还会从 SnowSQL 导入默认连接,默认连接不是命名连接。直接在配置文件的 [connections] 部分对其进行定义。因为 Snowflake CLI 要求所有连接都是命名连接,所以该命令定义了一个名为 [default] 的连接。如果要为默认连接使用其他名称,可以使用 --default-connection-name 选项对其进行指定。

如果 SnowSQL 连接与现有 Snowflake CLI 连接的名称匹配,命令提示符会询问是要覆盖现有连接,还是跳过导入该 SnowSQL 连接。

示例

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

snow helpers import-snowsql-connections
Copy

该命令在处理 SnowSQL 配置文件时,会显示进度,并在 Snowflake CLI config.toml 文件中已经定义了同名连接时提示确认。

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.
语言: 中文