pyspark.sql.Catalog.listDatabases

Catalog.listDatabases(pattern: Optional[str] = None) → List[pyspark.sql.catalog.Database][source]

Returns a list of databases available across all sessions.

New in version 2.0.0.

Parameters
patternstr

The pattern that the database name needs to match.

Returns
list

A list of Database.

Examples

>>> spark.catalog.listDatabases()
[Database(name='default', catalog='spark_catalog', description='default database', ...
>>> spark.catalog.listDatabases("def*")
[Database(name='default', catalog='spark_catalog', description='default database', ...
>>> spark.catalog.listDatabases("def2*")
[]