Admin Client
AdminClient provides database management operations. It uses the same database connection mode as Client, but only supports database management-related operations.
Connect to an embedded seekdb instance
Connect to a local embedded seekdb instance by using AdminClient.
import pyseekdb
# Embedded mode - Database management
admin = pyseekdb.AdminClient(path="./seekdb")
Parameter description:
| Parameter | Value Type | Required | Description | Example Value |
|---|---|---|---|---|
path | string | Optional | The path of the seekdb data directory. seekdb stores database files in this directory and loads them when it starts. | ./seekdb |
Connect to a remote server
Connect to a remote server by using AdminClient. This way, you can connect to a seekdb instance or an OceanBase Database instance.
tip
Example: Connect to a server mode seekdb instance
import pyseekdb
# Remote server mode - Database management
admin = pyseekdb.AdminClient(
host="127.0.0.1",
port=2881,
user="root",
password="" # Can be retrieved from SEEKDB_PASSWORD environment variable
)
Parameter description:
| Parameter | Value Type | Required | Description | Example Value |
|---|---|---|---|---|
host | string | Yes | The IP address of the server where the instance resides. | 127.0.0.1 |
prot | string | Yes | The port of the instance. The default value is 2881. | 2881 |
user | string | Yes | The username. The default value is root. | root |
password | string | Yes | The password corresponding to the username. If you do not specify password or specify an empty string, the system retrieves the password from the SEEKDB_PASSWORD environment variable. |
Example: Connect to an OceanBase Database instance
import pyseekdb
# Remote server mode - Database management
admin = pyseekdb.AdminClient(
host="127.0.0.1",
port=2881,
tenant="test"
user="root",
password="" # Can be retrieved from SEEKDB_PASSWORD environment variable
)
Parameter description:
| Parameter | Value Type | Required | Description | Example Value |
|---|---|---|---|---|
host | string | Yes | The IP address of the server where the database resides. | 127.0.0.1 |
prot | string | Yes | The port of the OceanBase Database instance. The default value is 2881. | 2881 |
tenant | string | No | The name of the tenant. This parameter is not required for a server mode seekdb instance, but is required for an OceanBase Database instance. The default value is sys. | test |
user | string | Yes | The username corresponding to the tenant. The default value is root. | root |
password | string | Yes | The password corresponding to the username. If you do not specify password or specify an empty string, the system retrieves the password from the SEEKDB_PASSWORD environment variable. |
APIs supported when you use AdminClient to connect to a database
The following APIs are supported when you use AdminClient to connect to a database.
| API | Description | Documentation Link |
|---|---|---|
create_database | Creates a new database. | Documentation |
get_database | Queries a specified database. | Documentation |
delete_database | Deletes a specified database. | Documentation |
list_databases | Lists all databases. | Documentation |