MSSQL.drop_schema

MSSQL.drop_schema(schema_names, confirmation_required=True, verbose=False)[source]

Delete/drop one or multiple schemas.

Parameters:
  • schema_names (str | Iterable[str]) – Name of a single schema or names of multiple schemas to be dropped.

  • confirmation_required (bool) – Whether to prompt a confirmation message before proceeding; defaults to True.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to False.

Examples:

>>> from pyhelpers.dbms import MSSQL
>>> testdb = MSSQL(database_name='testdb')
Creating a database: [testdb] ... Done.
Connecting <server_name>@localhost:1433/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.