PostgreSQL.drop_schema
- PostgreSQL.drop_schema(schema_names, confirmation_required=True, verbose=False)
Delete/drop one or multiple schemas.
- Parameters
schema_names (str or Iterable[str]) – name of one schema, or names of multiple schemas
confirmation_required (bool) – whether to prompt a message for confirmation to proceed, defaults to
True
verbose (bool or int) – whether to print relevant information in console as the function runs, defaults to
False
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. >>> new_schema_names = ['points', 'lines', 'polygons'] >>> for new_schema in new_schema_names: ... testdb.create_schema(new_schema, verbose=True) Creating a schema: "points" ... Done. Creating a schema: "lines" ... Done. Creating a schema: "polygons" ... Done. >>> new_schema_names_ = ['test_schema'] >>> testdb.drop_schema(new_schema_names + new_schema_names_, verbose=True) To drop the following schemas from postgres:***@localhost:5432/testdb: "points" "lines" "polygons" "test_schema" ? [No]|Yes: yes Dropping ... "points" ... Done. "lines" ... Done. "polygons" ... Done. "test_schema" (does not exist.) >>> testdb.drop_database(verbose=True) # Delete the database "testdb" To drop the database "testdb" from postgres:***@localhost:5432 ? [No]|Yes: yes Dropping "testdb" ... Done.