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)
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
name | string | Yes | The name of the database to be queried. | my_database |
tenant | string | No
| 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
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
name | string | Yes | The name of the queried database. | my_database |
tenant | string | No When you use embedded seekdb and server mode SeekDB, this parameter does not exist. | The tenant to which the queried database belongs. | test_tenant |
charset | string | No | The character set used by the queried database. | utf8mb4 |
collation | string | No | The collation used by the queried database. | utf8mb4_general_ci |
metadata | dict | No | Reserved field. |
Response example
Database: my_database, Charset: utf8mb4, collation:utf8mb4_general_ci, metadata:{}