PostgresOSM.get_database_size

PostgresOSM.get_database_size(database_name=None)

Get the size of a database in the PostgreSQL server being connected.

When database_name is None (default), the connected database is checked.

Parameters

database_name (str or None) – name of a database, defaults to None

Returns

size of the database

Return type

int

Example:

>>> from pyhelpers.sql import PostgreSQL

>>> testdb = PostgreSQL('localhost', 5432, username='postgres', database_name='testdb')
Password (postgres@localhost:5432): ***
Connecting postgres:***@localhost:5432/testdb ... Successfully.

>>> print(testdb.get_database_size())
7901 kB