pyspark.sql.Catalog.listDatabases#

Catalog.listDatabases(pattern=None)[source]#

Returns a list of databases available across all sessions.

New in version 2.0.0.

Parameters
patternstr, optional

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*")
[]