MSSQL.get_table_names

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

Get names of all tables stored in a schema.

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

  • verbose (bool | int) – whether to print relevant information in console, defaults to False

Returns:

table names of the given schema(s) schema_name

Return type:

dict

Examples:

>>> from pyhelpers.dbms import MSSQL

>>> mssql = MSSQL()
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': []}