在 Snowflake 中使用 Python 创建文件格式

File format creation using Python in Snowflake

我们正在使用 python 进行数据加载,因此我们需要使用 python 在雪花中创建文件格式。我试图通过 python 创建文件格式,但出现错误。

有人可以分享使用 python 创建文件格式的示例 python 脚本吗?

您可以通过Python游标执行您的文件格式DDL语句。

snowflake.connector 作为 sfc

# --Snowflake Connection Setup
cnx = sfc.connect(
user='user',
password=pwd,
account='account',
warehouse = 'warehouse',
database='database',
schema='schema',
role = 'role')
cnx.cursor().execute("create or replace file format mycsvformat type = 'CSV' 
field_delimiter '|' skip_header = 1;")