From 6c8dc4f2074c3d1f34db6a3550b03fc5adee5188 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Fri, 27 Jan 2023 13:36:51 +0100 Subject: [PATCH] Minor improvements in readme --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5d4b6f4..8258e82 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,9 @@ with Flow(...) as flow: remote_target_host="some-host-probably-mysql", remote_target_port=12345, ) + task_result = some_task_that_needs_the_tunnel(tunnel=tunnel) # Tunnel is now alive. tunnel.is_active == True - close_ssh_tunnel(tunnel=tunnel) + close_ssh_tunnel(tunnel=tunnel, upstream_tasks=[task_result]) ``` **Connect to a MySQL instance** @@ -82,11 +83,11 @@ with Flow(...) as flow: from lolafect.connections import connect_to_mysql, close_mysql_connection with Flow(...) as flow: - connection = connect_to_mysql.run( + connection = connect_to_mysql( mysql_credentials={...}, # You probably want to get this from TEST_LOLACONFIG.DW_CREDENTIALS ) - connection.cursor().execute("SELECT 1") - close_mysql_connection.run(connection=connection) + task_result = some_task_that_needs_mysql(connection=connection) + close_mysql_connection(connection=connection, upstream_tasks=[task_result]) # Want to connect through an SSH tunnel? Open the tunnel normally and then # override the host and port when connecting to MySQL. @@ -106,17 +107,17 @@ with Flow(...) as flow: remote_target_port=3306, ) - connection = connect_to_mysql.run( + connection = connect_to_mysql( mysql_credentials={...}, # You probably want to get this from TEST_LOLACONFIG.DW_CREDENTIALS overriding_host_and_port=get_local_bind_address_from_ssh_tunnel.run( tunnel=tunnel # This will open the connection through the SSH tunnel instead of straight to MySQL ), ) - connection.cursor().execute("SELECT 1") - - close_mysql_connection.run(connection=connection) - close_ssh_tunnel.run(tunnel=tunnel) + task_result = some_task_that_needs_mysql(connection=connection) + + mysql_closed = close_mysql_connection(connection=connection, upstream_tasks=[task_result]) + close_ssh_tunnel.run(tunnel=tunnel, upstream_tasks=[mysql_closed]) ``` ### Slack