MSSQL.get_primary_keys

MSSQL.get_primary_keys(table_name=None, schema_name=None, table_type='TABLE')

Get the primary keys of table(s).

Parameters
  • table_name (str or None) – name of a table in the currently-connected database; when table_name=None (default), get the primary keys of all existing tables

  • schema_name (str or None) – name of a schema, defaults to DEFAULT_SCHEMA when schema_name=None

  • table_type (str) – table type, defaults to 'TABLE'

Returns

a list of primary keys

Return type

list

Examples:

>>> from pyhelpers.dbms import MSSQL

>>> mssql = MSSQL()
Connecting <server_name>@localhost:1433/master ... Successfully.

>>> mssql.get_primary_keys()
{}