Module tripleblind.database_datasource
Classes
class DatabaseDatasourceAsset (uuid: UUID, connection_string: str = '')-
An abstract asset representing a Database Connection
Ancestors
Subclasses
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: bool | None = False, allow_overwrite: bool | None = False, session: Session | None = None) -> DatabaseDatasourceAsset | None-
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.
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: str | re.Pattern | None, namespace: uuid.UUID | None = None, owned: bool | None = False, owned_by: int | None = None, session: Session | None = None, exact_match: bool | None = True) -> DatabaseDatasourceAsset | None-
Search the Router index for an asset matching the given search
Args
search:strorre.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 team)
owned_by:int, optional- Only return owned assets owned by the given team 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
Instance variables
var connection_string : str
Methods
def retrieve_schema(self, params: Dict[str, str | float | int], silent: bool = False, job_name: str | None = None, session: Session | None = None) -> JobResult | None-
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
Static methods
def create(host: str, database: str, username: str, password: str, options: dict | None = None, port: int = 1433, name: str = '', desc: str = '', is_discoverable: bool | None = False, allow_overwrite: bool | None = False, session: Session | None = None) -> MSSQLDatabaseDatasource | None-
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.
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
class Neo4jDatabaseDatasource (uuid: UUID, connection_string: str = '')-
An asset representing a Neo4j database connection
Ancestors
Static methods
def create(host: str | None, username: str | None, password: str | None, connection: str | None = None, port: int | None = None, name: str = '', desc: str = '', is_discoverable: bool | None = False, allow_overwrite: bool | None = False, session: Session | None = None) -> Neo4jDatabaseDatasource | None-
Create a new Neo4jDatabaseDatasource
Args
host:str- The hostname of the database to connect to. Required if connection is not provided.
username:str- The username. Required if connection is not provided.
password:str- The password. Required if connection is not provided.
port:int, optional- The port number. Required if connection is not provided.
connection:str, optional- The connection string to the database. Must start with 'bolt://' or reference an environment variable in the format '{ENV:NEO4J_CONNECTION_ENV}'. If not provided, host, username, password, and port are required.
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.
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
Neo4jDatabaseDatasource- The new asset
Inherited members