PostgreSQL.schema_exists

PostgreSQL.schema_exists(schema_name)[source]

Check if a schema exists.

Parameters:

schema_name (str) – Name of the schema to check.

Returns:

True if the schema exists, otherwise False.

Return type:

bool

Examples:

>>> from pyhelpers.dbms import PostgreSQL
>>> testdb = PostgreSQL(database_name='testdb', verbose=True)
Password (postgres@localhost:5432): ***
Creating a database: "testdb" ... Done.
Connecting postgres:***@localhost:5432/testdb ... Successfully.
>>> testdb.schema_exists('public')
True
>>> testdb.schema_exists('test_schema')  # (if the schema 'test_schema' does not exist)
False
>>> testdb.drop_database(verbose=True)  # Delete the database "testdb"
To drop the database "testdb" from postgres:***@localhost:5432
? [No]|Yes: yes
Dropping "testdb" ... Done.