@@ -44,11 +44,6 @@ def app(ctx: Context) -> None:
4444 """Database Migration Assessment"""
4545
4646
47- @app .command (
48- name = "collect" ,
49- no_args_is_help = True ,
50- short_help = "Collect data from a source database." ,
51- )
5247@click .option (
5348 "--no-prompt" ,
5449 help = "Do not prompt for confirmation before executing check." ,
@@ -168,10 +163,11 @@ def _collect_data(
168163 database : str ,
169164 collection_identifier : str | None ,
170165 working_path : Path | None = None ,
166+ export_path : Path | None = None ,
167+ export_delimiter : str = "|" ,
171168) -> None :
172- working_path = working_path or Path ("tmp/" )
173169 _execution_id = f"{ src_info .db_type } _{ current_version !s} _{ datetime .now (tz = timezone .utc ).strftime ('%y%m%d%H%M%S' )} "
174- with get_duckdb_connection (working_path ) as local_db :
170+ with get_duckdb_connection (working_path = working_path , export_path = export_path ) as local_db :
175171 canonical_query_manager = next (provide_canonical_queries (local_db = local_db , working_path = working_path ))
176172 collection_extractor = CollectionExtractor (
177173 local_db = local_db ,
@@ -182,7 +178,9 @@ def _collect_data(
182178 collection_identifier = collection_identifier ,
183179 )
184180 collection_extractor .execute ()
185- collection_extractor .dump_database (working_path )
181+ if collection_extractor is not None and export_path is not None :
182+ collection_extractor .dump_database (export_path = export_path , delimiter = export_delimiter )
183+ console .rule ("Assessment complete." , align = "left" )
186184
187185
188186@app .command (
@@ -262,6 +260,24 @@ def _collect_data(
262260 required = False ,
263261 show_default = False ,
264262)
263+ @click .option (
264+ "--export" ,
265+ "-e" ,
266+ help = "Path to export the results." ,
267+ default = None ,
268+ type = click .Path (),
269+ required = False ,
270+ show_default = False ,
271+ )
272+ @click .option (
273+ "--working-path" ,
274+ "-wp" ,
275+ help = "Path to store the temporary artifacts during assessment." ,
276+ default = None ,
277+ type = click .Path (),
278+ required = False ,
279+ show_default = False ,
280+ )
265281def readiness_assessment (
266282 no_prompt : bool ,
267283 db_type : Literal ["mysql" , "postgres" , "mssql" , "oracle" ],
@@ -271,6 +287,8 @@ def readiness_assessment(
271287 port : int | None = None ,
272288 database : str | None = None ,
273289 collection_identifier : str | None = None ,
290+ export : str | None = None ,
291+ working_path : str | None = None ,
274292) -> None :
275293 """Process a collection of advisor extracts."""
276294 print_app_info ()
@@ -298,6 +316,8 @@ def readiness_assessment(
298316 ),
299317 database = database ,
300318 collection_identifier = collection_identifier ,
319+ working_path = Path (working_path ) if working_path else None ,
320+ export_path = Path (export ) if export else None ,
301321 )
302322 else :
303323 console .rule ("Skipping execution until input is confirmed" , align = "left" )
@@ -309,10 +329,11 @@ def _readiness_check(
309329 database : str ,
310330 collection_identifier : str | None ,
311331 working_path : Path | None = None ,
332+ export_path : Path | None = None ,
333+ export_delimiter : str = "|" ,
312334) -> None :
313- working_path = working_path or Path ("tmp/" )
314335 _execution_id = f"{ src_info .db_type } _{ current_version !s} _{ datetime .now (tz = timezone .utc ).strftime ('%y%m%d%H%M%S' )} "
315- with get_duckdb_connection (working_path ) as local_db :
336+ with get_duckdb_connection (working_path = working_path , export_path = export_path ) as local_db :
316337 workflow = ReadinessCheck (
317338 local_db = local_db ,
318339 src_info = src_info ,
@@ -325,8 +346,9 @@ def _readiness_check(
325346 console .print (Padding ("" , 1 , expand = True ))
326347 console .rule ("Processing collected data." , align = "left" )
327348 workflow .print_summary ()
328- if workflow .collection_extractor is not None :
329- workflow .collection_extractor .dump_database (working_path )
349+ if workflow .collection_extractor is not None and export_path is not None :
350+ workflow .collection_extractor .dump_database (export_path = export_path , delimiter = export_delimiter )
351+ console .rule ("Assessment complete." , align = "left" )
330352
331353
332354def print_app_info () -> None :
@@ -335,4 +357,4 @@ def print_app_info() -> None:
335357 table .add_row (
336358 f"[bold green]Google Database Migration Assessment[/] [cyan]version { current_version } [/]"
337359 )
338- console .print (table , width = 80 )
360+ console .print (table )
0 commit comments