PostgreSQL.disconnect_all_others¶
- PostgreSQL.disconnect_all_others()[source]¶
Terminate connections to all databases except the currently-connected one.
Examples:
>>> from pyhelpers.dbms import PostgreSQL >>> testdb = PostgreSQL(database_name='testdb', verbose=True) 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.