MSSQL.disconnect_database¶
- MSSQL.disconnect_database(database_name=None, verbose=False)[source]¶
Disconnect from a database.
- Parameters:
database_name (str | None) – Name of the database to disconnect from; if
database_name=None
(default), disconnects from the current database.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. >>> testdb.database_name 'testdb' >>> testdb.disconnect_database() >>> testdb.database_name 'master' >>> # Delete the database [testdb] >>> testdb.drop_database(database_name='testdb', verbose=True) To drop the database [testdb] from <server_name>@localhost:1433 ? [No]|Yes: yes Dropping [testdb] ... Done. >>> testdb.drop_database(database_name='testdb', verbose=True) The database [testdb] does not exist.