MSSQL.get_column_names¶
- MSSQL.get_column_names(table_name, schema_name=None)[source]¶
Retrieve column names of a table.
- Parameters:
table_name (str) – Name of the table to retrieve column names from.
schema_name (str | None) – Name of the schema where the table is located; defaults to
None
.
- Returns:
List of column names in the specified table in the currently-connected database.
- Return type:
list
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']} >>> mssql.get_column_names(table_name='MSreplication_options') ['optname', 'value', 'major_version', 'minor_version', 'revision', 'install_failures']