MSSQL.table_exists
- MSSQL.table_exists(table_name, schema_name=None)
Check whether a table exists.
- Parameters
table_name (str) – name of a table
schema_name (str or None) – name of a schema, defaults to
DEFAULT_SCHEMA
whenschema_name=None
- Returns
whether the table exists in the currently-connected database
- Return type
bool
Examples:
>>> from pyhelpers.dbms import MSSQL >>> mssql = MSSQL() Connecting <server_name>@localhost:1433/master ... Successfully. >>> mssql.table_exists(table_name='test_table') False >>> mssql.get_table_names() ['MSreplication_options', 'spt_fallback_db', 'spt_fallback_dev', 'spt_fallback_usg', 'spt_monitor'] >>> mssql.table_exists(table_name='MSreplication_options') True