Coverage for pystratum_cli/command/RoutineLoaderCommand.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from cleo.helpers import argument
3from pystratum_cli.command.BaseCommand import BaseCommand
6class RoutineLoaderCommand(BaseCommand):
7 """
8 Command for loading stored routines into a database instance from pseudo SQL files.
9 """
10 name = 'loader'
11 description = 'Command for loading stored routines into a database instance from pseudo SQL files.'
12 arguments = [argument(name='config_file', description='The stratum configuration file.'),
13 argument(name='file_names', description='Sources with stored routines', optional=True, multiple=True)]
15 # ------------------------------------------------------------------------------------------------------------------
16 def handle(self) -> int:
17 """
18 Executes constants command when StratumCommand is activated.
19 """
20 self._read_config_file()
22 factory = self._create_backend_factory()
23 worker = factory.create_routine_loader_worker(self._config, self._io)
24 file_names = self.argument('file_names')
26 if not worker:
27 self._io.title('Loader')
28 self._io.error('Loader command is not implemented by the backend')
29 return -1
31 return worker.execute(file_names)
33# ----------------------------------------------------------------------------------------------------------------------