Skip to main content

sqbooster

PyPI version Python Version License: MIT

A flexible Python library for database access with real typed tables, a chainable query builder, and easy backend switching.

Features

  • 6 backends, same API - SQLite, PostgreSQL, JSON files, Pickle files, Redis, MongoDB
  • Real typed tables - Integer, Text, Float, Boolean, Blob, JSON, and more
  • Chainable query builder - filter, order, select, paginate, chain
  • Django-style filter operators - __gt, __lt, __contains, __in, __like, and more
  • Pickle serialization - serialization="pickle" at the backend level
  • Key-value API - the v1 key-value interface still works for simple use cases
  • Zero config - SQLite in-memory is the default

Installation

pip install sqbooster

# Optional backends
pip install sqbooster[postgresql]   # PostgreSQL support
pip install sqbooster[redis]        # Redis support
pip install sqbooster[mongodb]      # MongoDB support
pip install sqbooster[all]          # Everything

Quick Start

import sqbooster

# One line to get a database
db = sqbooster.sqlite()

# Tables are created automatically from the data you insert
db.add("users", {"name": "Alice", "email": "alice@example.com", "age": 30})
db.add("users", {"name": "Bob", "email": "bob@example.com", "age": 25})

# Query with filter operators
active_users = db.find("users", age__gte=18, order_by="name")

# Chained filters
rich_active = db.find("users", age__gte=18, order_by="-age", limit=10)

# Get a single row
alice = db.get("users", name="Alice")

# Update and delete
db.update("users", {"age": 31}, name="Alice")
db.remove("users", name="Bob")

Switching Backends

Switch between backends by changing only the constructor:

import sqbooster

# SQLite
db = sqbooster.sqlite("myapp.db")

# JSON file
db = sqbooster.json("data.json")

# PostgreSQL (requires sqbooster[postgresql])
db = sqbooster.postgresql(host="localhost", name="mydb", user="me")

# Everything else stays the same
db.add("users", {"name": "Alice", "age": 30})
db.find("users", age__gte=18)

Explicit Table Definitions

When you need constraints like unique, nullable=False, or custom defaults:

from sqbooster.schema import Column
from sqbooster.types import Integer, Text, Float, Boolean

db.create_table("products", [
    Column("id", Integer(), primary_key=True, autoincrement=True),
    Column("name", Text(), nullable=False),
    Column("sku", Text(), unique=True, nullable=False),
    Column("price", Float(), nullable=False),
    Column("stock", Integer(), default=0),
    Column("active", Boolean(), default=True),
])

db.insert("products", {"name": "Widget", "sku": "W-001", "price": 9.99})

Query Builder

results = (db.query("users")
    .filter(age__gte=18, name__contains="a")
    .order_by("-age")
    .limit(10)
    .offset(0)
    .all())

count = db.query("users").filter(active=True).count()
first = db.query("users").filter(name="Alice").first()

Key-Value API

db = sqbooster.sqlite()

db.write("config:theme", {"dark": True, "font_size": 14})
print(db.read("config:theme"))

for key in db.keys("config:"):
    print(key, db.read(key))

Pickle Serialization

db = sqbooster.sqlite(serialization="pickle")

db.write("cache:results", [1, 2, {"nested": True}])
data = db.read("cache:results")

Documentation

Full documentation: https://sqbooster.github.io/sqbooster/

API Reference

SimpleClient Methods

Method Description
add(table, data) Insert one or more rows (auto-creates table)
get(table, **filters) Get a single row
find(table, **filters) Find rows matching filters
update(table, data, **filters) Update rows
remove(table, **filters) Delete rows
count(table, **filters) Count rows
exists(table, **filters) Check if rows exist
define(table, columns) Explicitly define a table

Filter Operators

Operator Meaning
__gt / __lt Greater/less than
__gte / __lte Greater/less than or equal
__ne Not equal
__contains LIKE %value%
__startswith LIKE value%
__endswith LIKE %value
__like Raw LIKE pattern
__in Value in list
__notin Value not in list
__isnull IS NULL / IS NOT NULL

Contributing

See CONTRIBUTING.md.

License

MIT License - see LICENSE.

Author

Ali Safamanesh (daradege@proton.me)

Metadata

Release files for sqbooster 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqbooster 2.0.0
File Size Uploaded Provenance
sqbooster-2.0.0.tar.gz 49.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sqbooster 2.0.0
File Interpreter ABI Platform
sqbooster-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 89.6 kB

Release files / sqbooster-2.0.0.tar.gz

Download URL sqbooster-2.0.0.tar.gz
Size 49.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bccaa8482d81c4ebb395b473d1e764ad44b6a6fc71624b28f07ee5c14447d689
BLAKE2b-256 checksum
How to use checksums
2caa10e3b80f8bcb093bd57786e018557c81f7eebca149ed77bed4b566640851
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / sqbooster-2.0.0-py3-none-any.whl

Download URL sqbooster-2.0.0-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1767e4360ebbb7813b4666af2a3c01b4d72d8a1f16d2cb074fa5968c7cba8c8a
BLAKE2b-256 checksum
How to use checksums
dfe233094e7867b92681933bd8281f3ccaec86318b80c0b4776045c8c0a860f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for sqbooster 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page