MSSQL.create_database¶
- MSSQL.create_database(database_name, verbose=False)[source]¶
Create a database.
- Parameters:
database_name (str) – Name of the database to be created.
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.create_database(database_name='testdb1', verbose=True) Creating a database: [testdb1] ... Done. >>> testdb.database_name 'testdb1' >>> # Delete the database [testdb1] >>> testdb.drop_database(verbose=True) To drop the database [testdb1] from <server_name>@localhost:5432 ? [No]|Yes: yes Dropping [testdb1] ... Done. >>> 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:5432 ? [No]|Yes: yes Dropping [testdb] ... Done. >>> testdb.database_name 'master'