Skip to main content

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:

ParameterValue TypeRequiredDescriptionExample Value
pathstringOptionalThe 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

Before you connect to a remote server, make sure that you have deployed a server mode seekdb instance or an OceanBase Database instance.
For information about how to deploy a server mode seekdb instance, see Overview.
For information about how to deploy an OceanBase Database instance, see Overview.

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:

ParameterValue TypeRequiredDescriptionExample Value
hoststringYesThe IP address of the server where the instance resides.127.0.0.1
protstringYesThe port of the instance. The default value is 2881.2881
userstringYesThe username. The default value is root.root
passwordstringYesThe 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:

ParameterValue TypeRequiredDescriptionExample Value
hoststringYesThe IP address of the server where the database resides.127.0.0.1
protstringYesThe port of the OceanBase Database instance. The default value is 2881.2881
tenantstringNoThe 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
userstringYesThe username corresponding to the tenant. The default value is root.root
passwordstringYesThe 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.

APIDescriptionDocumentation Link
create_databaseCreates a new database.Documentation
get_databaseQueries a specified database.Documentation
delete_databaseDeletes a specified database.Documentation
list_databasesLists all databases.Documentation