PostgresOSM.drop_database¶
-
PostgresOSM.
drop_database
(database_name=None, confirmation_required=True, verbose=False)¶ Drop a database from the PostgreSQL server being connected.
If
database_name
isNone
(default), drop the current database.- Parameters
database_name (str or None) – database to be disconnected, defaults to
None
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
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. >>> # Delete the database "testdb" >>> testdb.drop_database(verbose=True) To drop the database "testdb" from postgres:***@localhost:5432 ? [No]|Yes: yes Dropping "testdb" ... Done. >>> testdb.database_exists(database_name='testdb') False >>> testdb.drop_database(database_name='testdb', verbose=True) The database "testdb" does not exist. >>> print(testdb.database_name) postgres