PostgresOSM.schema_exists

PostgresOSM.schema_exists(schema_name)

Check if a schema exists in the PostgreSQL server being connected.

Parameters

schema_name (str) – name of a schema

Returns

True if the schema exists, False otherwise

Return type

bool

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.

>>> testdb.schema_exists('public')
True

>>> testdb.schema_exists('test_schema')  # (if the schema 'test_schema' does not exist)
False