forked from bcgov/lear
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
24051 Tombstone pipeline (first cut) (bcgov#3077)
* 24051 - tombstone pipeline (first cut) Signed-off-by: Hongjing Chen <[email protected]> * update extract script Signed-off-by: Hongjing Chen <[email protected]> * update makefile Signed-off-by: Hongjing Chen <[email protected]> * update corp_type_cd in query Signed-off-by: Hongjing Chen <[email protected]> * add todo Signed-off-by: Hongjing Chen <[email protected]> * seperate batch configs for delete & tombstone flow Signed-off-by: Hongjing Chen <[email protected]> --------- Signed-off-by: Hongjing Chen <[email protected]>
- Loading branch information
1 parent
5260ebb
commit cf2fc72
Showing
11 changed files
with
1,114 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from config import get_named_config | ||
from prefect import task | ||
from sqlalchemy import create_engine, text | ||
from sqlalchemy.engine import Engine | ||
|
||
|
||
@task | ||
def get_config(): | ||
config = get_named_config() | ||
return config | ||
|
||
|
||
@task | ||
def check_db_connection(db_engine: Engine): | ||
with db_engine.connect() as conn: | ||
res = conn.execute(text('SELECT current_database()')).scalar() | ||
if not res: | ||
raise ValueError("Failed to retrieve the current database name.") | ||
print(f'✅ Connected to database: {res}') | ||
|
||
|
||
@task | ||
def colin_init(config): | ||
try: | ||
engine = create_engine(config.SQLALCHEMY_DATABASE_URI_COLIN_MIGR) | ||
check_db_connection(engine) | ||
return engine | ||
except Exception as e: | ||
raise Exception('Failed to create engine for COLIN DB') from e | ||
|
||
|
||
@task | ||
def lear_init(config): | ||
try: | ||
engine = create_engine( | ||
config.SQLALCHEMY_DATABASE_URI, | ||
**config.SQLALCHEMY_ENGINE_OPTIONS | ||
) | ||
check_db_connection(engine) | ||
return engine | ||
except Exception as e: | ||
raise Exception('Failed to create engine for LEAR DB') from e | ||
|
||
|
||
@task | ||
def auth_init(config): | ||
try: | ||
engine = create_engine(config.SQLALCHEMY_DATABASE_URI_AUTH) | ||
check_db_connection(engine) | ||
return engine | ||
except Exception as e: | ||
raise Exception('Failed to create engine for AUTH DB') from e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.