PostgresOSM.create_database¶
-
PostgresOSM.
create_database
(database_name, verbose=False)¶ An alternative to sqlalchemy_utils.create_database.
- Parameters
database_name (str) – name of a database
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. >>> testdb.create_database('testdb1', verbose=True) Creating a database: "testdb1" ... Done. >>> print(testdb.database_name) testdb1 >>> # Delete the database "testdb" >>> testdb.drop_database(verbose=True) To drop the database "testdb1" from postgres:***@localhost:5432 ? [No]|Yes: yes Dropping "testdb1" ... Done.