Skip to main content

list_databases - Get the database list

The list_databases() method is used to retrieve the database list in the instance.

info

This API is only available when using the AdminClient. For more information about the AdminClient, see Admin Client.

Prerequisites

  • You have installed pyseekdb. For more information about how to install pyseekdb, see Quick Start.

  • You have connected to the database. For more information about how to connect to the database, see Admin Client.

Request parameters

list_databases(limit=None, offset=None, tenant=DEFAULT_TENANT)
ParameterTypeRequiredDescriptionExample value
limitintOptionalThe maximum number of databases to return.2
offsetintOptionalThe number of databases to skip.3
tenantstringOptional
  • When using embedded seekdb and server mode seekdb, this parameter is not required.
  • When using OceanBase Database, this parameter is required. The default value is sys.
The tenant to which the queried database belongs.test_tenant

Request example

# List all databases
import pyseekdb

# Embedded mode
admin = pyseekdb.AdminClient(path="./seekdb")

# list database
databases = admin.list_databases(2,3)
for db in databases:
print(f"Database: {db.name}, Charset: {db.charset}, collation:{db.collation}, metadata:{db.metadata}")

Response parameters

ParameterTypeRequiredDescriptionExample value
namestringYesThe name of the queried database.my_database
tenantstringOptional
When using embedded seekdb and server mode SeekDB, this parameter is not available.
The tenant to which the queried database belongs.test_tenant
charsetstringOptionalThe character set of the queried database.utf8mb4
collationstringOptionalThe collation of the queried database.utf8mb4_general_ci
metadatadictOptionalReserved field. No data is returned.

Response example

Database: test, Charset: utf8mb4, collation:utf8mb4_general_ci, metadata:{}
Database: my_database, Charset: utf8mb4, collation:utf8mb4_general_ci, metadata:{}

References