MSSQL.get_row_count

MSSQL.get_row_count(table_name, schema_name=None)

Get row count of a table in a database.

Parameters
  • table_name (str) – name of a table in the currently-connected database

  • schema_name (str or None) – schema name of the given table, defaults to None

Returns

count of rows in the given table

Return type

int

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']

>>> mssql.get_row_count(table_name='MSreplication_options')
3