PostgreSQL.schema_exists
- PostgreSQL.schema_exists(schema_name)[source]
Check whether a schema exists.
- Parameters:
schema_name (str) – name of a schema
- Returns:
whether the schema exists
- Return type:
bool
Examples:
>>> from pyhelpers.dbms import PostgreSQL >>> testdb = PostgreSQL('localhost', 5432, 'postgres', database_name='testdb') 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.