Database Class

Define a database class for a DataTransfer Component or Job.

Inheritance
azure.ai.ml.entities._mixins.DictMixin
Database
azure.ai.ml.entities._mixins.RestTranslatableMixin
Database

Constructor

Database(*, query: str | None = None, table_name: str | None = None, stored_procedure: str | None = None, stored_procedure_params: List[Dict] | None = None, connection: str | None = None)

Keyword-Only Parameters

Name Description
query
str

The SQL query to retrieve data from the database.

table_name
str

The name of the database table.

stored_procedure
str

The name of the stored procedure.

stored_procedure_params

The parameters for the stored procedure.

connection
str

The connection string for the database. The credential information should be stored in the connection.

Examples

Create a database and querying a database table.


   from azure.ai.ml.entities._inputs_outputs import Database

   # For querying a database table
   source_database = Database(query="SELECT * FROM my_table", connection="azureml:my_azuresql_connection")

   # For invoking a stored procedure with parameters
   stored_procedure_params = [
       {"name": "job", "value": "Engineer", "type": "String"},
       {"name": "department", "value": "Engineering", "type": "String"},
   ]
   source_database = Database(
       stored_procedure="SelectEmployeeByJobAndDepartment",
       stored_procedure_params=stored_procedure_params,
       connection="azureml:my_azuresql_connection",
   )


Methods

get
has_key
items
keys
update
values

get

get(key: Any, default: Any | None = None) -> Any

Parameters

Name Description
key
Required
default
Default value: None

has_key

has_key(k: Any) -> bool

Parameters

Name Description
k
Required

items

items() -> list

keys

keys() -> list

update

update(*args: Any, **kwargs: Any) -> None

values

values() -> list

Attributes

stored_procedure_params

Get or set the parameters for the stored procedure.

Returns

Type Description
List[<xref:StoredProcedureParameter>]

The parameters for the stored procedure.