Improve logging.
This commit is contained in:
parent
caa69d85cd
commit
28831bea8c
1 changed files with 9 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import datetime
|
||||
|
||||
import prefect
|
||||
from prefect import task
|
||||
from trino.auth import BasicAuthentication
|
||||
import trino
|
||||
|
|
@ -14,12 +15,15 @@ def connect_to_trino(
|
|||
"""
|
||||
Open a connection to the specified trino instance and return it.
|
||||
|
||||
|
||||
:param trino_credentials: a dict with the host, port, user and password.
|
||||
:param http_schema: which http schema to use in the connection.
|
||||
:return:
|
||||
"""
|
||||
print("Connecting to Trino.")
|
||||
logger = prefect.context.get("logger")
|
||||
logger.info(
|
||||
f"Connecting to Trino at {trino_credentials['host']}:{trino_credentials['port']}."
|
||||
)
|
||||
|
||||
connection = trino.dbapi.connect(
|
||||
host=trino_credentials["host"],
|
||||
port=trino_credentials["port"],
|
||||
|
|
@ -30,6 +34,8 @@ def connect_to_trino(
|
|||
trino_credentials["password"],
|
||||
),
|
||||
)
|
||||
print("Connected to Trino.")
|
||||
logger.info(
|
||||
f"Connected to Trino at {trino_credentials['host']}:{trino_credentials['port']}."
|
||||
)
|
||||
|
||||
return connection
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue