Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Am 5973 #7228

Closed
wants to merge 3 commits into from
Closed

Am 5973 #7228

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions redash/query_runner/snowflake.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import os
import tempfile

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization

try:
import snowflake.connector

Expand Down Expand Up @@ -96,16 +102,31 @@ def _get_connection(self):
else:
host = "{}.snowflakecomputing.com".format(account)

connection = snowflake.connector.connect(
user=self.configuration["user"],
password=self.configuration["password"],
account=account,
region=region,
host=host,
application="Redash/{} (Snowflake)".format(__version__.split("-")[0]),
)
connection_parameters = {
"user": self.configuration["user"],
"password": self.configuration["password"],
"account": account,
"region": region,
"host": host,
"application": "Redash/{} (Snowflake)".format(__version__.split("-")[0]),
}

private_key_content = os.getenv("SNOWFLAKE_PRIVATE_KEY")
private_key_password = os.getenv("SNOWFLAKE_KEY_PASSWORD")

if private_key_content and private_key_password:

key_file = tempfile.NamedTemporaryFile(delete=False)
key_file.write(private_key_content.encode('UTF-8'))
key_file.close()

connection_parameters['private_key_file'] = key_file.name
connection_parameters["private_key_file_pwd"] = private_key_password

# password is not needed
connection_parameters.pop('password')

return connection
return snowflake.connector.connect(**connection_parameters)

def _column_name(self, column_name):
if self.configuration.get("lower_case_columns", False):
Expand Down
15 changes: 15 additions & 0 deletions requirements_ds_obmedia.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
google-api-python-client==1.7.11
protobuf==3.17.3
gspread==3.1.0
mysqlclient==2.1.1
oauth2client==4.1.3
boto3>=1.10.0,<1.11.0
botocore>=1.13,<1.14.0
sasl>=0.1.3
requests_aws_sign==0.1.5
snowflake-connector-python==3.0.4
python-rapidjson==0.8.0
pandas==1.3.4
nzpy>=1.15
nzalchemy
pyarrow==10.0.0
Loading