MSSQL.get_table_names

MSSQL.get_table_names(schema_name=None, verbose=False)[source]

Get names of all tables stored in one or multiple schemas.

Parameters:
  • schema_name (str | list | None) – Name of a single schema, or names of multiple schemas; defaults to DEFAULT_SCHEMA when schema_name=None.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to False.

Returns:

Dictionary containing table names grouped by schema(s) specified in schema_name.

Return type:

dict

Examples:

>>> from pyhelpers.dbms import MSSQL
>>> mssql = MSSQL(verbose=True)
Connecting <server_name>@localhost:1433/master ... Successfully.
>>> mssql.get_table_names()
{'dbo': ['MSreplication_options',
  'spt_fallback_db',
  'spt_fallback_dev',
  'spt_fallback_usg',
  'spt_monitor',
  'test_table']}
>>> mssql.get_table_names(schema_name=['dbo', 'sys'])
{'dbo': ['MSreplication_options',
  'spt_fallback_db',
  'spt_fallback_dev',
  'spt_fallback_usg',
  'spt_monitor',
  'test_table'],
 'sys': []}