MSSQL.has_dtypes
- MSSQL.has_dtypes(table_name, dtypes, schema_name=None)
Check whether a table contains data of a certain data type or data types.
- Parameters
table_name (str) – name of a table in the currently-connected database
dtypes (str or Sequence[str]) – data types, such as
'geometry'
,'hierarchyid'
,'varbinary'
schema_name (str or None) – name of a schema, defaults to
DEFAULT_SCHEMA
whenschema_name=None
- Returns
data type, whether the table has this data type and the corresponding column names
- Return type
Generator[str, bool, list]
Examples:
>>> from pyhelpers.dbms import MSSQL >>> mssql = MSSQL() Connecting <server_name>@localhost:1433/master ... Successfully. >>> mssql.get_table_names() ['MSreplication_options', 'spt_fallback_db', 'spt_fallback_dev', 'spt_fallback_usg', 'spt_monitor'] >>> rslt = mssql.has_dtypes(table_name='spt_monitor', dtypes='varbinary') >>> list(rslt) [('varbinary', False, [])] >>> rslt = mssql.has_dtypes(table_name='spt_monitor', dtypes=['geometry', 'int']) >>> list(rslt) [('geometry', False, []), ('int', True, ['cpu_busy', 'io_busy', 'idle', 'pack_received', 'pack_sent', 'connections', 'pack_errors', 'total_read', 'total_write', 'total_errors'])]