🚀 ZTeraDB Quickstart Guide (10-Minute Beginner Setup)
Welcome!
This guide is designed for complete beginners and developers who want to start using ZTeraDB in Python as fast as possible.
Follow this guide step-by-step and you will run your first ZTeraDB query in under 10 minutes.
✅ 1. Install ZTeraDB Python Client
Install using pip:
pip install zteradb
Or install directly from GitHub (latest build):
pip install git+https://github.com/zteradb/zteradb-python
✅ 2. Add Your .env Configuration
Inside your project, create:
.env
Add:
CLIENT_KEY=YOUR_CLIENT_KEY
ACCESS_KEY=YOUR_ACCESS_KEY
SECRET_KEY=YOUR_SECRET_KEY
DATABASE_ID=YOUR_DATABASE_ID
ZTERADB_HOST=db1.zteradb.com
ZTERADB_PORT=7777
ZTERADB_ENV=dev
REQUEST_DATA_TYPE=json
⚠️ Never commit .env to GitHub!
✅ 3. Create a Connection File
Create:
db.py
Add this:
import os
from dotenv import load_dotenv
from zteradb.zteradb_config import ZTeraDBConfig, Options, ENVS, ResponseDataTypes
from zteradb.zteradb_connection import ZTeraDBConnectionAsync
load_dotenv()
def get_db():
config = ZTeraDBConfig(
client_key=os.getenv("CLIENT_KEY"),
access_key=os.getenv("ACCESS_KEY"),
secret_key=os.getenv("SECRET_KEY"),
database_id=os.getenv("DATABASE_ID"),
env=ENVS(os.getenv("ZTERADB_ENV", "dev")),
response_data_type=ResponseDataTypes(os.getenv("REQUEST_DATA_TYPE", "json")),
options=Options(connection_pool=dict(min=1, max=5))
)
return ZTeraDBConnectionAsync(
os.getenv("ZTERADB_HOST"),
int(os.getenv("ZTERADB_PORT")),
config
)
✅ 4. Run Your First SELECT Query
Create:
test.py
Add:
import asyncio
from db import get_db
from zteradb.zteradb_query import ZTeraDBQuery
async def main():
db = get_db()
query = ZTeraDBQuery("user").select()
result = await db.run(query)
print(result)
await db.close()
asyncio.run(main())
Run it:
python test.py
🎉 If everything is correct, your user rows will print!
⚡ 5. INSERT Example
query = (
ZTeraDBQuery("user")
.insert()
.fields({
"email": "test@example.com",
"password": "pwd",
"status": True
})
)
result = await db.run(query)
print(result["last_insert_id"])
⚙ 6. UPDATE Example
query = (
ZTeraDBQuery("user")
.update()
.fields({"status": False})
.filter({"id": 1})
)
❌ 7. DELETE Example
query = (
ZTeraDBQuery("user")
.delete()
.filter({"id": 5})
)
🔍 8. Filtering (Simple)
query.filter({"status": True})
🔥 9. Filtering (Advanced)
from zteradb.filter_condition import ZTGT, ZTMUL
query.filterCondition(
ZTGT([
ZTMUL(["price", "quantity"]),
500
])
)
🎉 10. You Are Ready!
You now know:
- How to install ZTeraDB
- How to configure it
- How to connect
- How to run all basic queries
👉 Next recommended file:
troubleshooting