RAISS Zineb
04/18/2022, 11:39 PMKevin Kho
Anna Geller
RAISS Zineb
04/19/2022, 11:53 AMAnna Geller
RAISS Zineb
04/19/2022, 12:01 PMAnna Geller
driver=[x for x in pyodbc.drivers() if ' for SQL Server' in x][-1]
RAISS Zineb
04/19/2022, 2:21 PMAnna Geller
RAISS Zineb
04/19/2022, 6:51 PMPrefectSecret
tasks to
load them."""
pass
with Flow("postgres_example") as flow:
postgres_pwd = PrefectSecret("POSTGRES_PASSWORD")
query = define_query()
define_Connection(query=query,pwd=postgres_pwd)
my_secret = PrefectSecret("MYSECRET")
res = my_task(credentials=my_secret)
# Register the flow under the "tutorial" project
flow.register(project_name="Step1")
if name == "__main__":
flow.run()Anna Geller
@task
def define_connection(query,pwd):
cnxn = pyodbc.connect(driver=[x for x in pyodbc.drivers() if ' for SQL Server' in x][-1], server="EQ-EQ6288793\SQLEXPRESS", database="OTI_Djoliba", uid="sa", pwd="xxx")
cursor = cnxn.cursor()
#insert dataframe
cursor.execute(query)
for row in cursor:
print('row = %r' % (row,))
cnxn.commit()
RAISS Zineb
04/19/2022, 9:01 PMKevin Kho
RAISS Zineb
04/19/2022, 9:41 PMAnna Geller
RAISS Zineb
04/19/2022, 11:10 PMAnna Geller
pyodbc.drivers()
to see what drivers do you have in your environment and to confirm that pyodbc
can find those?RAISS Zineb
04/19/2022, 11:18 PMAnna Geller