Add example in readme.
This commit is contained in:
parent
58261b1a69
commit
52ad640766
1 changed files with 25 additions and 0 deletions
25
README.md
25
README.md
|
|
@ -120,6 +120,31 @@ with Flow(...) as flow:
|
|||
close_ssh_tunnel.run(tunnel=tunnel, upstream_tasks=[mysql_closed])
|
||||
```
|
||||
|
||||
**Use SQL transactions and dry running**
|
||||
|
||||
```python
|
||||
from lolafect.connections import connect_to_mysql, close_mysql_connection
|
||||
from lolafect.utils import begin_sql_transaction, end_sql_transaction
|
||||
|
||||
with Flow(...) as flow:
|
||||
connection = connect_to_mysql(
|
||||
mysql_credentials={...}, # You probably want to get this from TEST_LOLACONFIG.DW_CREDENTIALS
|
||||
)
|
||||
transaction_started = begin_sql_transaction(connection)
|
||||
task_result = some_task_that_needs_mysql(
|
||||
connection=connection,
|
||||
upstream_task=[transaction_started]
|
||||
)
|
||||
transaction_finished = end_sql_transaction(
|
||||
connection,
|
||||
dry_run=False, # True means rollback, False means commit changes
|
||||
upstream_tasks=[task_result]
|
||||
)
|
||||
|
||||
close_mysql_connection(connection=connection, upstream_tasks=[transaction_finished])
|
||||
|
||||
```
|
||||
|
||||
### Use Great Expectations
|
||||
|
||||
**Run a Great Expectations validation on a MySQL query**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue