Module tripleblind.database_datasource

Classes

class DatabaseDatasourceAsset (uuid: UUID, connection_string: str = '')

An abstract asset representing a Database Connection

Ancestors

Subclasses

Class variables

var connection_string : str

Static methods

def cast(asset: Asset) -> DatabaseDatasourceAsset

Convert a generic Asset into a DatabaseDatasourceAsset

This should only be used on an asset known to be a DatabaseDatasource, no validation occurs during the cast.

Args

asset : Asset
A generic Asset

Returns

DatabaseDatasourceAsset
A DatabaseDatasourceAsset object
def create(connection: str, name: str, desc: str, is_discoverable: Optional[bool] = False, cost: Optional[int] = 1, allow_overwrite: Optional[bool] = False, session: Optional[Session] = None) -> Optional[DatabaseDatasourceAsset]

Create a new DatabaseDatasourceAsset

Args

connection : str
The connection string to the database
name : str
The name of the asset
desc : str
A description of the asset
is_discoverable : bool, optional
Is the asset discoverable by others? Defaults to False.
cost : int, optional
The cost of the asset. Defaults to 1.
allow_overwrite : bool, optional
Can the asset be overwritten? Defaults to False.
session : Session, optional
A connection session. If not specified, the default session is used.

Returns

DatabaseDatasourceAsset
The new asset
def find(search: Union[str, re.Pattern, ForwardRef(None)], namespace: Optional[uuid.UUID] = None, owned: Optional[bool] = False, owned_by: Optional[int] = None, session: Optional[Session] = None, exact_match: Optional[bool] = True) -> Optional[DatabaseDatasourceAsset]

Search the Router index for an asset matching the given search

Args

search : str or re.Pattern, optional
Either an asset ID or a search pattern applied to asset names and descriptions. A simple string will match a substring or the entire string if exact_match is True, or a regular expression can be passed for complex searches.
namespace : UUID, optional
The UUID of the user to which this asset belongs. None indicates any user, NAMESPACE_DEFAULT_USER indicates the current API user.
owned : bool, optional
Only return owned assets (either personally or by the current user's organization)
owned_by : int, optional
Only return owned assets owned by the given organization ID
session : Session, optional
A connection session. If not specified, the default session is used.
exact_match : bool, optional
When the 'search' is a string, setting this to True will perform an exact match. Ignored for regex patterns, defaults to True.

Raises

TripleblindAssetError
Thrown when multiple assets are found which match the search.

Returns

ReportAsset
A single asset, or None if no match found

Methods

def retrieve_schema(self, params: Dict[str, Union[str, float, int]], silent: bool = False, job_name: Optional[str] = None, session: Optional[Session] = None) -> Optional[JobResult]

Retrieve the schema associated with this database connection

Args

params : Dict[str, Union[str, float, int]]
A dictionary of parameter names and the value to be used in the report.
silent : bool, optional
Suppress status messages during execution? Default is to show messages.
job_name : Optional[str], optional
The name associate with the job. Default name is "Blind Report - ASSET_NAME".
session : Optional[Session], optional
A connection session. If not specified, the default session is used.

Raises

TripleblindReportError
Report failed to run

Returns

TableAsset
The generated output, or None if the report fails

Inherited members

class MSSQLDatabaseDatasource (uuid: UUID, connection_string: str = '')

An asset representing a Microsoft SQL Server database connection

Ancestors

Class variables

var connection_string : str

Static methods

def create(host: str, database: str, username: str, password: str, options: Optional[dict] = None, port: int = 1433, name: str = '', desc: str = '', is_discoverable: Optional[bool] = False, cost: Optional[int] = 1, allow_overwrite: Optional[bool] = False, session: Optional[Session] = None) -> Optional[MSSQLDatabaseDatasource]

Create a new MSSQLDatabaseDatasource

Args

host : str
The hostname of the database to connect to.
database : str
The database name
username : str
The username
password : str
The password
options : dict, optional
Additional connection options. Defaults to None.
port : int, optional
The port number. Defaults to 1433.
name : str, optional
The name of the asset
desc : str, optional
A description of the asset
is_discoverable : bool, optional
Is the asset discoverable by others? Defaults to False.
cost : int, optional
The cost of the asset. Defaults to 1.
allow_overwrite : bool, optional
Can the asset be overwritten? Defaults to False.
session : Session, optional
A connection session. If not specified, the default session is used.

Returns

MSSQLDatabaseDatasource
The new asset

Inherited members