Skip to main content

get_database - Get the specified database

The get_database() method is used to obtain the information of the specified database.

info

This method can be used only when you connect to the database by 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

get_database(name, tenant=DEFAULT_TENANT)
ParameterTypeRequiredDescriptionExample value
namestringYesThe name of the database to be queried.my_database
tenantstringNo
  • When you use embedded seekdb and server mode seekdb, you do not need to specify this parameter.
  • When you use OceanBase Database, you must specify this parameter.
The tenant to which the database belongs.test_tenant

Request example

import pyseekdb

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

# Get database
db = admin.get_database("my_database")
# 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
tenantstringNo
When you use embedded seekdb and server mode SeekDB, this parameter does not exist.
The tenant to which the queried database belongs.test_tenant
charsetstringNoThe character set used by the queried database.utf8mb4
collationstringNoThe collation used by the queried database.utf8mb4_general_ci
metadatadictNoReserved field.

Response example

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

References