PostgresOSM.create_schema

PostgresOSM.create_schema(schema_name, verbose=False)

Create a new schema in the database being connected.

Parameters
  • schema_name (str) – name of a schema

  • verbose (bool or int) – whether to print relevant information in console as the function runs, defaults to False

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.

>>> test_schema_name = 'test_schema'

>>> testdb.create_schema(test_schema_name, verbose=True)
Creating a schema: "test_schema" ... Done.

>>> testdb.schema_exists(test_schema_name)
True

>>> testdb.drop_schema(test_schema_name, verbose=True)
To drop the schema "test_schema" from postgres:***@localhost:5432/testdb
? [No]|Yes: yes
Dropping "test_schema" ... Done.

>>> # Delete the database "testdb"
>>> testdb.drop_database(verbose=True)
To drop the database "testdb" from postgres:***@localhost:5432
? [No]|Yes: yes
Dropping "testdb" ... Done.