Minor improvements in readme

This commit is contained in:
Pablo Martin 2023-01-27 13:36:51 +01:00
parent b3123c2470
commit 6c8dc4f207

View file

@ -73,8 +73,9 @@ with Flow(...) as flow:
remote_target_host="some-host-probably-mysql", remote_target_host="some-host-probably-mysql",
remote_target_port=12345, remote_target_port=12345,
) )
task_result = some_task_that_needs_the_tunnel(tunnel=tunnel)
# Tunnel is now alive. tunnel.is_active == True # 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** **Connect to a MySQL instance**
@ -82,11 +83,11 @@ with Flow(...) as flow:
from lolafect.connections import connect_to_mysql, close_mysql_connection from lolafect.connections import connect_to_mysql, close_mysql_connection
with Flow(...) as flow: 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 mysql_credentials={...}, # You probably want to get this from TEST_LOLACONFIG.DW_CREDENTIALS
) )
connection.cursor().execute("SELECT 1") task_result = some_task_that_needs_mysql(connection=connection)
close_mysql_connection.run(connection=connection) close_mysql_connection(connection=connection, upstream_tasks=[task_result])
# Want to connect through an SSH tunnel? Open the tunnel normally and then # Want to connect through an SSH tunnel? Open the tunnel normally and then
# override the host and port when connecting to MySQL. # override the host and port when connecting to MySQL.
@ -106,17 +107,17 @@ with Flow(...) as flow:
remote_target_port=3306, 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 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( 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 tunnel=tunnel # This will open the connection through the SSH tunnel instead of straight to MySQL
), ),
) )
connection.cursor().execute("SELECT 1") task_result = some_task_that_needs_mysql(connection=connection)
close_mysql_connection.run(connection=connection) mysql_closed = close_mysql_connection(connection=connection, upstream_tasks=[task_result])
close_ssh_tunnel.run(tunnel=tunnel) close_ssh_tunnel.run(tunnel=tunnel, upstream_tasks=[mysql_closed])
``` ```
### Slack ### Slack