Skip to main content

ZTeraDB Configuration Guide

This guide explains how to configure the ZTeraDB Python client using the ZTeraDBConfig class.


๐ŸŽฏ What is ZTeraDBConfig?

ZTeraDBConfig is a PHP configuration object that contains all authentication details, environment settings, and optional connection settings required to connect your application to ZTeraDB Server.

It is required for every ZTeraDB connection.


๐Ÿงฉ Full Structure

from zteradb.zteradb_config import (
ZTeraDBConfig,
ENVS,
ResponseDataTypes,
Options
)

config = ZTeraDBConfig(
client_key="string",
access_key="string",
secret_key="string",
database_id="string",
env=ENVS("dev | staging | qa | prod"),
response_data_type=ResponseDataTypes("json"),
options=Options(connection_pool=dict(
min=0,
max=0
))
)

๐Ÿ”Ž Field-by-field Explanation

๐Ÿ”‘ client_keyโ€‹

  • Your unique ZTeraDB account key.
  • Get it from: Dashboard โ†’ Security Credentials.

๐Ÿ” access_keyโ€‹

  • Required for authenticating outgoing requests.
  • You can generate multiple access keys.
  • Only one active access key is allowed at a time.

๐Ÿงฉ secret_keyโ€‹

  • Secret signature key used to verify request authenticity.
  • You will only see it once when creating it.
  • Never share it or commit it to Git.

๐Ÿ—„ database_idโ€‹

  • Unique ID of your ZTeraDB database.
  • Example:
    "7K3WHGOJKJJEJ3PFJM407QO25F"

๐ŸŒ envโ€‹

Defines which ZTeraDB environment you want to connect to.

Allowed values:

  • dev -> Development Environment
  • staging -> Staging Environment
  • qa -> QA Environment
  • prod -> Production Environment

Usage example:

env=ENVS("dev")

๐Ÿ“ฆ response_data_typeโ€‹

  • Currently supports only "json":
response_data_type=ResponseDataTypes("json")
  • Future formats may be added later.

โš™๏ธ options.connection_poolโ€‹

You can control automatic connection pooling:

FieldMeaning
minMinimum connections ZTeraDB should maintain
maxMaximum number of allowed connections

Example:

options=Options(connection_pool=dict(
min=2,
max=10
))

If omitted โ†’ ZTeraDB automatically manages the pool.


๐Ÿงช Complete Example

from zteradb.zteradb_config import (
ZTeraDBConfig,
Options,
ENVS,
ResponseDataTypes
)

config = ZTeraDBConfig(
client_key="<Your ZTeraDB client key>",
access_key="<Your ZTeraDB access key>",
secret_key="<Your ZTeraDB secret key>",
database_id="<Your ZTeraDB database id>",
env=ENVS("dev"),
response_data_type=ResponseDataTypes("json"),
options=Options(connection_pool=dict(min=1, max=5))
)

โš ๏ธ Common Mistakes (Read This!)

โŒ Wrong environment name
โœ” Use only: "dev", "staging", "qa", "prod"

โŒ Missing secret key
โœ” Ensure all fields are present in environment variables

โŒ Credentials stored inside code
โœ” Always use .env variables to store keys

โŒ No connection pool in high-traffic apps
โœ” Set min and max based on workload


๐ŸŽ‰ You are ready to create a connection!

Continue to:
๐Ÿ‘‰ zteradb-connection.md