get
Implements the database get subcommand for the Merlin CLI.
This module defines the DatabaseGetCommand class, which enables users to retrieve
data from the Merlin database. Users can query individual entities by identifier,
retrieve all entities of a given type (optionally filtered), or dump the entire
database contents.
The command supports dynamic registration of entity types using the ENTITY_REGISTRY
and integrates filter support for more precise queries. It also ensures compatibility
with both local and distributed configurations through the Merlin configuration system.
Main Capabilities:
- database get <entity> <ids...>: Retrieve one or more specific entities.
- database get all-<entity>: Retrieve all instances of an entity type with optional filters.
- database get everything: Retrieve all data from all registered entity types.
DatabaseGetCommand
Bases: CommandEntryPoint
Handles the database get subcommand, which retrieves data from the
Merlin database based on entity type, identifiers, and filters.
Methods:
| Name | Description |
|---|---|
add_parser |
Adds the |
process_command |
Dispatches the appropriate get operation based on CLI args. |
_print_items |
Outputs items or logs a fallback message. |
_get_and_print |
Fetches and prints specific entities. |
_get_all_and_print |
Fetches and prints filtered entities of a type. |
Source code in merlin/cli/commands/database/get.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
add_parser(database_commands)
Add the database get subcommand parser to the CLI argument parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database_commands
|
ArgumentParser
|
The subparsers object to which the |
required |
Source code in merlin/cli/commands/database/get.py
process_command(args)
Process the database get command using the provided CLI arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
An argparse Namespace containing user arguments. |
required |