Skip to content

Commit

Permalink
Import-API snowflake key pair auth support
Browse files Browse the repository at this point in the history
  • Loading branch information
josemaria-vilaplana committed Jan 8, 2025
1 parent 753bee5 commit 5f1d19b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions raster_loader/cli/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def snowflake(args=None):
default=None,
)
@click.option("--role", help="The role to use for the file upload.", default=None)
@click.option("--warehouse", help="Name of the default warehouse to use.", default=None)
@click.option(
"--file_path", help="The path to the raster file.", required=False, default=None
)
Expand Down Expand Up @@ -119,6 +120,7 @@ def upload(
private_key_path,
private_key_passphrase,
role,
warehouse,
file_path,
file_url,
database,
Expand Down Expand Up @@ -189,6 +191,7 @@ def upload(
database=database,
schema=schema,
role=role,
warehouse=warehouse,
)

source = file_path if is_local_file else file_url
Expand Down Expand Up @@ -254,6 +257,7 @@ def upload(
default=None,
)
@click.option("--role", help="The role to use for the file upload.", default=None)
@click.option("--warehouse", help="Name of the default warehouse to use.", default=None)
@click.option("--database", help="The name of the database.", required=True)
@click.option("--schema", help="The name of the schema.", required=True)
@click.option("--table", help="The name of the table.", required=True)
Expand All @@ -266,6 +270,7 @@ def describe(
private_key_path,
private_key_passphrase,
role,
warehouse,
database,
schema,
table,
Expand Down Expand Up @@ -298,6 +303,7 @@ def describe(
database=database,
schema=schema,
role=role,
warehouse=warehouse,
)
df = connector.get_records(fqn, limit)
print(f"Table: {fqn}")
Expand Down
4 changes: 4 additions & 0 deletions raster_loader/io/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(
private_key_path,
private_key_passphrase,
role,
warehouse,
):
if not _has_snowflake:
import_error_snowflake()
Expand All @@ -57,6 +58,7 @@ def __init__(
database=database.upper(),
schema=schema.upper(),
role=role.upper() if role is not None else None,
warehouse=warehouse,
)
elif private_key_path is not None:
self.client = snowflake.connector.connect(
Expand All @@ -68,6 +70,7 @@ def __init__(
database=database.upper(),
schema=schema.upper(),
role=role.upper() if role is not None else None,
warehouse=warehouse,
)
else:
self.client = snowflake.connector.connect(
Expand All @@ -77,6 +80,7 @@ def __init__(
database=database.upper(),
schema=schema.upper(),
role=role.upper() if role is not None else None,
warehouse=warehouse,
)

def band_rename_function(self, band_name: str):
Expand Down

0 comments on commit 5f1d19b

Please sign in to comment.