PostgreSQL.disconnect_all_others

PostgreSQL.disconnect_all_others()

Kill connections to all databases except the currently-connected one.

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.

>>> testdb.database_name
'testdb'

>>> testdb.disconnect_all_others()
>>> testdb.database_name
'testdb'

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