Skip to main content

Official Python Driver for MaazDB

Project description

MaazDB-Py 🐍

The Official Python Driver for MaazDB

License: MIT Python Security Website

maazdb-py is a pure-Python client library for interacting with the MaazDB engine. It implements the custom MaazDB binary protocol over a secure TLS 1.3 socket, allowing Python applications to communicate with your database safely and efficiently.


✨ Features

  • Secure by Default: Automatic TLS 1.3 encryption for all communications.
  • Pure Python: No heavy C-extensions; easy to install and cross-platform.
  • Context Manager Support: Use with statements for safe connection handling.
  • Binary Protocol: Optimized communication using the MaazDB Binary Protocol v1.
  • Lightweight: Minimal dependencies.

📦 Installation

From PyPI

pip install maazdb-py

From Source

git clone https://github.com/42Wor/maazdb-py.git
cd maazdb-py
pip install .

🛠 Quick Start

Basic Usage

from maazdb import MaazDB

# 1. Initialize the client
db = MaazDB()

try:
    # 2. Connect securely
    db.connect(host="127.0.0.1", port=8888, user="admin", password="password")
    print("✓ Connected to MaazDB")

    # 3. Execute SQL
    db.query("CREATE DATABASE analytics;")
    db.query("USE analytics;")
    db.query("CREATE TABLE logs (id SERIAL PRIMARY KEY, message TEXT);")
    
    # 4. Insert and Fetch
    db.query("INSERT INTO logs (message) VALUES ('System started');")
    results = db.query("SELECT * FROM logs;")
    print(f"Results:\n{results}")

except Exception as e:
    print(f"An error occurred: {e}")

finally:
    # 5. Always close the connection
    db.close()

Using Context Managers (Recommended)

The driver supports the with statement, which automatically closes the connection even if an error occurs.

from maazdb import MaazDB

with MaazDB() as db:
    db.connect("127.0.0.1", 8888, "admin", "password")
    result = db.query("SELECT count(*) FROM users;")
    print(f"Total users: {result}")

📋 API Reference

MaazDB()

The main class to interact with the database.

  • .connect(host, port, user, password): Establishes a TLS 1.3 connection and performs the handshake.
  • .query(sql_string): Sends a SQL query to the server and returns the result as a string.
  • .close(): Safely closes the socket connection.

🔐 Security & Protocol

The driver communicates using the MaazDB Binary Protocol v1. All data is packed as Big Endian (>I).

Step Type Description
Handshake 0x10 [Type] [Len] [User\0Pass\0Signature]
Query 0x20 [Type] [Len] [SQL String]
Success 0x02 [Type] [Len] [Result Data]
Error 0x03 [Type] [Len] [Error Message]

👩‍💻 Development & Contributing

If you are interested in contributing to the driver or building from source, please refer to the DEVELOPER.md file for:

  • Project structure
  • Setting up a development environment
  • Building and publishing to PyPI

📄 License

Distributed under the MIT License. See LICENSE for more information.


Created for the MaazDB Ecosystem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maazdb_py-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maazdb_py-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file maazdb_py-1.0.0.tar.gz.

File metadata

  • Download URL: maazdb_py-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for maazdb_py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a5b353942c926edc4b0985929b167107930ba7e0e8a316ea47068a811f2b1f50
MD5 0c91d1cd7fc750e3e08858b30e910285
BLAKE2b-256 340153540c70de177219dbfa68c7f59888aebcb400bb38dcf6443e1eedc41c58

See more details on using hashes here.

File details

Details for the file maazdb_py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: maazdb_py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for maazdb_py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1535994ce5266b01a762d270b7bea852dab211951625027acf85c61d59d8b00b
MD5 e8dbb91ced7e49ff9cab7635236fc1b1
BLAKE2b-256 e3eff91fd30e5ac57f0b5875a11e9c001b297fd2030f2d3d665c1dd84a86642f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page