MSSQL.get_row_count

MSSQL.get_row_count(table_name, schema_name=None)[source]

Get the row count of a table.

Parameters:
  • table_name (str) – Name of the table to get row count from.

  • schema_name (str | None) – Name of the schema where the table is located; defaults to None.

Returns:

Number of rows in the specified table in the currently-connected database.

Return type:

int

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_row_count(table_name='MSreplication_options')
3