pyspark.sql.Catalog.databaseExists

Catalog.databaseExists(dbName: str) → bool[source]

Check if the database with the specified name exists.

New in version 3.3.0.

Parameters
dbNamestr

name of the database to check existence

Returns
bool

Indicating whether the database exists

Examples

>>> spark.catalog.databaseExists("test_new_database")
False
>>> df = spark.sql("CREATE DATABASE test_new_database")
>>> spark.catalog.databaseExists("test_new_database")
True
>>> df = spark.sql("DROP DATABASE test_new_database")