MSSQL.get_primary_keys¶
- MSSQL.get_primary_keys(table_name=None, schema_name=None, table_type='TABLE')[source]¶
Retrieve the primary keys of table(s) from the currently-connected database.
- Parameters:
table_name (str | None) – Name of a specific table to retrieve primary keys from; when
table_name=None
(default), retrieves primary keys for all tables.schema_name (str | None) – Name of the schema where the table(s) are located; defaults to
DEFAULT_SCHEMA
(i.e.'master'
) ifschema_name=None
.table_type (str) – Type of table to consider; defaults to
'TABLE'
.
- Returns:
The primary keys for the specified table(s).
- Return type:
list
Examples:
>>> from pyhelpers.dbms import MSSQL >>> mssql = MSSQL(verbose=True) Connecting <server_name>@localhost:1433/master ... Successfully. >>> mssql.get_primary_keys() {}