mstrio > datasources > embedded_connection

class mstrio.datasources.embedded_connection.EmbeddedConnection(connection, datasource_id)

Bases: EntityBase

Datasource connection configuration object that represents an embedded connection template for the datasource.

Parameters:
  • connection (Connection) –

  • datasource_id (str) –

connection

A Strategy One connection object.

id

Unique datasource connection ID.

name

Unique datasource connection name.

datasource_id

ID of the corresponding datasource instance.

description

Datasource connection description.

execution_mode

ExecutionMode Enum specifying how SQL statements will be executed on a physical database connection made.

max_cancel_attempt_time

Number of seconds before being timed out when attempting to make a connection.

max_query_exe_time

Number of seconds during which a query must be executed before being timed out.

max_connection_attempt_time

Number of seconds connection attempts to be made before timing out.

connection_lifetime

Number of seconds of the connection lifetime.

connection_idle_timeout

Number of seconds before being timed out when the connection is idle.

char_encoding_windows

CharEncoding Enum specifying the encoding across connection for Windows drivers.

char_encoding_unix

CharEncoding Enum specifying the encoding across connection for Unix drivers.

table_prefix

String prefixed to the names of all temporary tables created by the Query Engine for this connection during report execution with this string.

connection_string

Database connection string.

parameterized_queries

Specifies whether parameterized queries are enabled.

extended_fetch

Specifies whether or not to use the extended fetch ODBC call to retrieve data from the database connection.

datasource_login

DatasourceLogin object or ID

database_type

Database type

database_version

Database version

driver_type

DriverType Enum specifying Driver used for database connection.

oauth_parameter

Used for authentication with oAuth.

type

Object type

subtype

Object subtype

date_created

Creation time, DateTime object

date_modified

Last modification time, DateTime object

owner

User object that is the owner

acg

Object access rights. It a bit vector where bits are defined at [EnumDSSXMLAccessRightFlags].

acl

Object access control list

iam

List of projects to which the fence is applied.

resource

The url of configured Web API for OAuth authentication usage.

scope

List of delegated permissions that the app is requesting.

enable_sso

Specifies whether to use Single Sign-On.

alter(description=None, execution_mode=None, max_cancel_attempt_time=None, max_query_exe_time=None, max_connection_attempt_time=None, connection_lifetime=None, connection_idle_timeout=None, char_encoding_windows=None, char_encoding_unix=None, table_prefix=None, connection_string=None, parameterized_queries=None, extended_fetch=None, driver_type=None, oauth_parameter=None, resource=None, scope=None, enable_sso=None, comments=None)

Alter the datasource connection properties.

Parameters:
  • description (str | None) – Datasource connection description.

  • execution_mode (str | ExecutionMode | None) – ExecutionMode Enum specifying how SQL statements will be executed on a physical database connection made.

  • max_cancel_attempt_time (int | None) – Number of seconds before being timed out when attempting to make a connection.

  • max_query_exe_time (int | None) – Number of seconds during which a query must be executed before being timed out.

  • max_connection_attempt_time (int | None) – Number of seconds connection attempts to be made before timing out.

  • connection_lifetime (int | None) – Number of seconds of the connection lifetime.

  • connection_idle_timeout (int | None) – Number of seconds before being timed out when the connection is idle.

  • char_encoding_windows (str | CharEncoding | None) – CharEncoding Enum specifying the encoding across connection for Windows drivers.

  • char_encoding_unix (str | CharEncoding | None) – CharEncoding Enum specifying the encoding across connection for Unix drivers.

  • table_prefix (str | None) – String prefixed to the names of all temporary tables created by the Query Engine for this connection during report execution with this string.

  • connection_string (str | None) – Database connection string.

  • parameterized_queries (bool | None) – Specifies whether parameterized queries are enabled.

  • extended_fetch (bool | None) – Specifies whether or not to use the extended fetch ODBC call to retrieve data from the database connection.

  • driver_type (str | DriverType | None) – DriverType Enum specifying Driver used for database connection.

  • datasource_loginDatasourceLogin object or ID

  • driver_type – ENUM Drivers used for database connection.

  • database_type – Database type

  • database_version – Database version

  • resource (str | None) – The url of configured Web API for OAuth authentication usage.

  • scope (str | None) – List of delegated permissions that the app is requesting.

  • enable_sso (bool | None) – Specifies whether to use Single Sign-On.

  • oauth_parameter (str | None) –

  • comments (str | None) –

Return type:

None

classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

fetch(attr=None)

Fetch the latest object’s state from the I-Server.

Note

This method can overwrite local changes made to the object.

Parameters:
  • attr (Optional[str]) – Attribute name to be fetched. If not specified

  • dictionary. (it will use all getters specified in _API_GETTERS) –

  • None. (Defaults to) –

Raises:

ValueError – If attr cannot be fetched.

Return type:

None

classmethod from_dict(source, connection, to_snake_case=True, with_missing_value=False)
Overrides Dictable.from_dict() to instantiate an object from

a dictionary without calling any additional getters.

Parameters:
  • cls (T) – Class (type) of an object that should be created.

  • source (dict[str, Any]) – a dictionary from which an object will be constructed.

  • connection (Connection) – A Strategy One Connection object.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case, default True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

An object of type T.

Return type:

T

list_properties(excluded_properties=None)

Fetches all attributes from the server and converts all properties of the object to a dictionary.

Parameters:

excluded_properties (list[str], optional) – A list of object properties that should be excluded from the dict. Defaults to None.

Returns:

A dictionary which keys are object’s attribute names, and

which values are object’s attribute values.

Return type:

dict

print()

Pretty Print all properties of the object.

Return type:

None

classmethod to_csv(objects, name, path=None, properties=None)

Exports MSTR objects to a csv file.

Optionally, saves only the object properties specified in the properties parameter.

Parameters:
  • objects (T | list[T]) – List of objects of the same type that

  • exported. (will be) –

  • name (str) – The name of the csv file ending with ‘.csv’

  • path (Optional[str], optional) – A path to the directory where the file will be saved. Defaults to None.

  • properties (Optional[list[str]], optional) – A list of object’s attribute names that should be included in the exported file. Defaults to None.

Raises:
  • TypeError – If objects is not of type T or list of type T

  • objects.

Return type:

None

to_dataframe()

Converts all properties of the object to a dataframe.

Returns:

A DataFrame object containing object properties.

Return type:

DataFrame

to_dict(camel_case=True)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters:

camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

update_properties()

Save compatible local changes of the object attributes to the I-Server. Changes are retrieved from the self._altered_properties dictionary. After the process of update has finished, self._altered_properties is cleared. For this method to work properly, you must override the _alter_properties() method in a subclass.

Raises:

requests.HTTPError – If I-Server raises exception

Return type:

None