Laura Vaida
07/02/2021, 10:56 AMFor convenience, you can use the snowflake.sqlalchemy.URL method to construct the connection string and connect to the database. The following example constructs the same connection string from the previous example:
from snowflake.sqlalchemy import URL
from sqlalchemy import create_engine
engine = create_engine(URL(
account = 'myorganization-myaccount',
user = 'testuser1',
password = '0123456',
database = 'testdb',
schema = 'public',
warehouse = 'testwh',
role='myrole',
))
I want to create an engine with passing the input for URL with **
instead of putting every variable
but I dont know how to write the input, it should be a str format
that's what I tried, maybe you have an idea how input data should look like
###selecting order data
@task(log_stdout=True)
def create_engine(snowflake_salesforce):
config = configparser.ConfigParser()
engine=create_engine(URL(**config[snowflake_salesforce]))
with Flow('UWG-Mail') as flow:
snowflake_credentials=PrefectSecret("Snowflake")
connection=create_engine(snowflake_salesforce=snowflake_credentials)
but resulting in this error
[12:03 Uhr] Unexpected error: TypeError("unhashable type: 'dict'")
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48, in inner
new_state = method(self, state, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 863, in get_task_run_state
value = prefect.utilities.executors.run_task_with_timeout(
File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 298, in run_task_with_timeout
return task.run(*args, **kwargs) # type: ignore
File "<input>", line 36, in create_engine
File "/usr/local/lib/python3.8/configparser.py", line 959, in __getitem__
if key != self.default_section and not self.has_section(key):
File "/usr/local/lib/python3.8/configparser.py", line 668, in has_section
return section in self._sections
TypeError: unhashable type: 'dict'
Marko Herkaliuk
07/02/2021, 11:22 AMLaura Vaida
07/02/2021, 11:23 AMMarko Herkaliuk
07/02/2021, 11:23 AMfrom prefect.client import Secret
config = Secret("Snowflake").get()
@task(log_stdout=True)
def create_engine(snowflake_cfg):
engine=create_engine(URL(**snowflake_cfg))
with Flow('UWG-Mail') as flow:
connection=create_engine(snowflake_salesforce=config)
Laura Vaida
07/02/2021, 12:10 PMMarko Herkaliuk
07/02/2021, 12:27 PMLaura Vaida
07/02/2021, 12:39 PMMarko Herkaliuk
07/02/2021, 12:42 PMfrom prefect.client import Secret
config = Secret("Snowflake").get()
from local env and saw what do you getLaura Vaida
07/02/2021, 2:42 PMKevin Kho
07/06/2021, 1:37 PMLaura Vaida
07/07/2021, 2:21 PM