tables.BaseTable
Base class representing a database table.
Usage
tables.BaseTable(net_table)Attributes
| Name | Description |
|---|---|
| columns | Get the columns for the table. |
| description | Get the table description. |
| display_name | Get the display name for the table. |
| name | Get the table name. |
columns
Get the columns for the table.
columns: BaseColumns
description
Get the table description.
description: str
display_name
Get the display name for the table.
display_name: str
name
Get the table name.
name: str
Methods
| Name | Description |
|---|---|
| __init__() | Initialize a new table wrapper. |
| __repr__() | Get string representation. |
| add_user_defined_column() | Add a user defined column to table. |
| delete() |
Create a DELETE query for this table.
|
| get_muids() | Get a list of MUIDs for the table. |
| insert() | Insert a row with given values. |
| select() |
Create a SELECT query for this table.
|
| to_dataframe() | Convert the table data to a pandas DataFrame. |
| update() |
Create an UPDATE query for this table.
|
__init__()
Initialize a new table wrapper.
Usage
__init__(net_table)Parameters
net_table: Any- The underlying .NET IMuTable object
__repr__()
Get string representation.
Usage
__repr__()Returns
str- Class name and table display name.
add_user_defined_column()
Add a user defined column to table.
Usage
add_user_defined_column(column_name, column_data_type, column_header=None)Equivalent to table.columns.add_user_defined, so it is safe to call repeatedly.
Parameters
column_name: str-
Name of the column in the database. Case-insensitive.
column_data_type: str-
Data type of the column. One of ‘integer’, ‘double’, ‘string’, ‘datetime’, in any casing.
column_header: str | None = None- Name of the column as displayed in the MIKE+ GUI. None uses the column_name.
Returns
str-
MUID of the column’s record in
m_UserDefinedColumn.
Raises
ValueError- If the column already exists with a different data type, or is a standard MIKE+ column.
delete()
Create a DELETE query for this table.
Usage
delete()Returns
DeleteQuery- A new DeleteQuery object
get_muids()
Get a list of MUIDs for the table.
Usage
get_muids(order_by=None, descending=False)Parameters
order_by: str or None = None-
Column to order the MUIDs by
descending: bool = False- Whether to order in descending order
Returns
list of str- A list of MUIDs
insert()
Insert a row with given values.
Usage
insert(values, execute=True)Parameters
values: dict[str, Any]-
Column-value pairs to insert.
execute: bool = True- If True, executes immediately (default). If False, returns an InsertQuery.
Returns
str or InsertQuery- When execute=True, returns the MUID of the inserted row. When execute=False, returns an InsertQuery instance.
Notes
User-defined columns cannot be set via command-based insert in the .NET application. Handling of user-defined columns is performed in InsertQuery when the query is executed.
select()
Create a SELECT query for this table.
Usage
select(columns=None)Parameters
columns: str or list of str = None- The column or columns to select
Returns
SelectQuery- A new SelectQuery object
to_dataframe()
Convert the table data to a pandas DataFrame.
Usage
to_dataframe()Returns
pandas.DataFrame- A pandas DataFrame containing all table data
update()
Create an UPDATE query for this table.
Usage
update(values)Parameters
values: dict of str to Any- Column-value pairs to set in the UPDATE
Returns
UpdateQuery- A new UpdateQuery object