pyseekdb is a Python client provided by OceanSeek. It implements a set of APIs to support connections to remote servers.
pyseekdb connects to OceanSeek through the Client and AdminClient interfaces. The differences between the Client and AdminClient interfaces are as follows:
AdminClient: Supports only database management-related operations. For example, creating databases, retrieving databases, and deleting databases.Client: Used to perform database operations, such as querying data, inserting data, creating tables, and deleting tables.
Prerequisites
- OceanSeek has been deployed. For information about how to deploy OceanSeek, see Choose an appropriate deployment plan.
- pyseekdb has been deployed. For information about how to deploy pyseekdb, see Deployment overview.
Connect to a remote server
Connect to a remote server by using AdminClient
Connect to OceanSeek by using AdminClient.
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 |
Value examples |
|---|---|---|---|---|
host |
string | Required | The IP address of the server where the database is located. | 127.0.0.1 |
prot |
string | Required | The port of OceanSeek. The default value is 2881. | 2881 |
tenant |
string | Optional | Tenant name. The default is sys. | test |
user |
string | Required | Username corresponding to the tenant. Default is root. | root |
password |
string | Required | The password of the user. If not provided,passwordor an empty string is entered, the system will useSEEKDB_PASSWORDEnvironment variable retrieval. |
For more information about AdminClient, see pyseekdb-AdminClient.
Connect to a remote server by using Client
Connect to OceanSeek by using Client.
import pyseekdb
# Create remote server client (OceanSeek Server)
client = pyseekdb.Client(
host="127.0.0.1", # Server host
port=2881, # Server port (default: 2881)
tenant="test", # Tenant name
database="test", # Database name
user="root", # Username (default: "root")
password="" # Password (can be retrieved from SEEKDB_PASSWORD environment variable)
)
Parameter description:
Parameter |
Value type |
Required |
Description |
Value examples |
|---|---|---|---|---|
host |
string | Required | The IP address of the server where the database is located. | 127.0.0.1 |
prot |
string | Required | The port of OceanSeek. The default value is 2881. | 2881 |
tenant |
string | Optional | Tenant name. The default is sys. | test |
database |
string | Required | The name of the database. | test |
user |
string | Required | Username corresponding to the tenant. Default is root. | root |
password |
string | Required | The password corresponding to the user. If not provided,passwordor an empty string is specified, the system will useSEEKDB_PASSWORDEnvironment variable retrieval. |
For more information about Client, see pyseekdb-Clien.