PostgreSQL.get_database_names¶
- PostgreSQL.get_database_names(names_only=True)[source]¶
Retrieve the names of all existing databases.
- Parameters:
names_only (bool) – Whether to return only the names of the databases; defaults to
True
.- Returns:
A list of database names if
names_only
isTrue
; otherwise, a dataframe containing detailed information.- Return type:
list | pandas.DataFrame
Examples:
>>> from pyhelpers.dbms import PostgreSQL >>> # Connect the default database 'postgres' >>> postgres = PostgreSQL(verbose=True) Password (postgres@localhost:5432): *** Connecting postgres:***@localhost:5432/postgres ... Successfully. >>> isinstance(postgres.get_database_names(), list) True >>> 'postgres' in postgres.get_database_names() True