StructuredDataDriver

class inmydata.StructuredData.StructuredDataDriver(tenant: str, server: str = 'inmydata.com', user: str | None = None, session_id: str | None = None, logging_level: int | None = 20, log_file: str | None = None)

Bases: object

A driver class for interacting with structured data in the inmydata platform. This class provides methods to retrieve data based on subjects, fields, and filters. It uses the inmydata API to fetch data and returns it as a pandas DataFrame.

tenant

The tenant identifier for the inmydata platform.

Type:

str

server

The server address for the inmydata platform, default is “inmydata.com”.

Type:

str

user

The user for whom the driver is initialized, if None, no user is set. Useful to identify the user when generating a chart (see https://developer.inmydata.com/a/solutions/articles/36000577995?portalId=36000061664).

Type:

Optional[str]

session_id

The session ID for the driver, if None, no session ID is set. Useful to identify the session when generating a chart (see https://developer.inmydata.com/a/solutions/articles/36000577995?portalId=36000061664).

Type:

Optional[str]

logging_level

The logging level for the logger, default is logging.INFO.

Type:

Optional[int]

log_file

The file to log messages to, if None, logs will be printed to the console.

Type:

Optional[str]

Members

__init__(tenant: str, server: str = 'inmydata.com', user: str | None = None, session_id: str | None = None, logging_level: int | None = 20, log_file: str | None = None)

Initializes the StructuredDataDriver with the specified tenant, server, logging level, and log file.

Parameters:
  • tenant (str) – The tenant identifier for the inmydata platform.

  • server (str) – The server address for the inmydata platform, default is “inmydata.com”.

  • user (Optional[str]) – The user for whom the driver is initialized, if None, no user is set. Useful to identify the user when generating a chart.

  • session_id (Optional[str]) – The session ID for the driver, if None, no session ID is set. Useful to identify the session when generating a chart.

  • logging_level (int) – The logging level for the logger, default is logging.INFO.

  • log_file (Optional[str]) – The file to log messages to, if None, logs will be printed to the console.

get_chart(subject: str, rowfields: list[str], columnfields: list[str], metricfields: list[str], filters: list[AIDataFilter], charttype: ChartType, caption: str)

Generates a chart based on the specified subject, row fields, column fields, metric fields, filters, chart type, user, and caption. For details on showing charts in your app, see https://developer.inmydata.com/a/solutions/articles/36000577995?portalId=36000061664

Parameters:
  • subject (str) – The subject to query data from.

  • rowfields (list[str]) – The list of fields to use as rows in the chart.

  • columnfields (list[str]) – The list of fields to use as columns in the chart.

  • metricfields (list[str]) – The list of fields to use as metrics in the chart.

  • filters (list[AIDataFilter]) – The list of filters to apply to the query.

  • charttype (ChartType) – The type of chart to generate.

  • caption (str) – The caption for the chart.

Returns:

The ID of the generated visualisation.

Return type:

str

get_data(subject: str, fields: list[str], filters: list[AIDataFilter])

Retrieves data from the inmydata platform based on the specified subject, fields, and filters.

Parameters:
  • subject (str) – The subject to query data from.

  • fields (list[str]) – The list of fields to retrieve.

  • filters (list[AIDataFilter]) – The list of filters to apply to the query.

Returns:

A pandas DataFrame containing the retrieved data.

Return type:

pd.DataFrame

get_data_simple(subject: str, fields: list[str], simplefilters: list[AIDataSimpleFilter], caseSensitive: bool | None = True)

Retrieves data from the inmydata platform based on the specified subject, fields, and simple filters.

Parameters:
  • subject (str) – The subject to query data from.

  • fields (list[str]) – The list of fields to retrieve.

  • simplefilters (list[AIDataSimpleFilter]) – The list of simple filters to apply to the query.

  • caseSensitive (Optional[bool]) – Whether the filter should be case sensitive. Defaults to True.

Returns:

A pandas DataFrame containing the retrieved data.

Return type:

pd.DataFrame