msticpy.data.core.data_providers module
Data provider loader.
- class msticpy.data.core.data_providers.QueryProvider(data_environment: Union[str, DataEnvironment], driver: Optional[DriverBase] = None, query_paths: Optional[List[str]] = None, **kwargs)
Bases:
object
Container for query store and query execution provider.
Instances of this class hold the query set and execution methods for a specific data environment.
Query provider interface to queries.
- Parameters
data_environment (Union[str, DataEnvironment]) – Name or Enum of environment for the QueryProvider
driver (DriverBase, optional) – Override the builtin driver (query execution class) and use your own driver (must inherit from DriverBase)
query_paths (List[str]) – Additional paths to look for query definitions.
kwargs – Other arguments are passed to the data provider driver.
See also
DataProviderBase
base class for data query providers.
- add_connection(connection_str: Optional[str] = None, alias: Optional[str] = None, **kwargs)
Add an additional connection for the query provider.
- Parameters
connection_str (Optional[str], optional) – Connection string for the provider, by default None
alias (Optional[str], optional) – Alias to use for the connection, by default None
kwargs (Dict[str, Any]) – Other parameters passed to the driver constructor.
Notes
Some drivers may accept types other than strings for the connection_str parameter.
- browse(**kwargs)
Return QueryProvider query browser.
- Parameters
kwargs – passed to SelectItem constructor.
- Returns
SelectItem browser for TI Data.
- Return type
- browse_queries(**kwargs)
Return QueryProvider query browser.
- Parameters
kwargs – passed to SelectItem constructor.
- Returns
SelectItem browser for TI Data.
- Return type
- connect(connection_str: Optional[str] = None, **kwargs)
Connect to data source.
- Parameters
connection_str (str) – Connection string for the data source
- property connected: bool
Return True if the provider is connected.
- Returns
True if the provider is connected.
- Return type
bool
- property connection_string: str
Return provider connection string.
- Returns
Provider connection string.
- Return type
str
- exec_query(query: str, **kwargs) Union[DataFrame, Any]
Execute simple query string.
- Parameters
query (str) – [description]
use_connections (Union[str, List[str]]) –
query_options (Dict[str, Any]) – Additional options passed to query driver.
kwargs (Dict[str, Any]) – Additional options passed to query driver.
- Returns
Query results - a DataFrame if successful or a KqlResult if unsuccessful.
- Return type
Union[pd.DataFrame, Any]
- get_query(query_name: str) str
Return the raw query text for query_name.
- Parameters
query_name (str) – The name of the query.
- import_query_file(query_file: str)
Import a yaml data source definition.
- Parameters
query_file (str) – Path to the file to import
- property instance: Optional[str]
Return instance name, if any for provider.
- Returns
The instance name or None for drivers that do not support multiple instances.
- Return type
Optional[str]
- list_connections() List[str]
Return a list of current connections or the default connection.
- Returns
The alias and connection string for each connection.
- Return type
List[str]
- classmethod list_data_environments() List[str]
Return list of current data environments.
- Returns
List of current data environments
- Return type
List[str]
- list_queries(substring: Optional[str] = None) List[str]
Return list of family.query in the store.
- Parameters
substring (Optional[str]) – Optional pattern - will return only queries matching the pattern, default None.
- Returns
List of queries
- Return type
List[str]
- query_help(query_name: str)
Print help for query_name.
- Parameters
query_name (str) – The name of the query.
- property query_time
Return the default QueryTime control for queries.
- property schema: Dict[str, Dict]
Return current data schema of connection.
- Returns
Data schema of current connection.
- Return type
Dict[str, Dict]
- property schema_tables: List[str]
Return list of tables in the data schema of the connection.
- Returns
Tables in the of current connection.
- Return type
List[str]