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)

Download files

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

Source Distribution

sqbooster-2.0.0.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

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

sqbooster-2.0.0-py3-none-any.whl (40.0 kB view details)

Uploaded Python 3

File details

Details for the file sqbooster-2.0.0.tar.gz.

File metadata

  • Download URL: sqbooster-2.0.0.tar.gz
  • Upload date:
  • Size: 49.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for sqbooster-2.0.0.tar.gz
Algorithm Hash digest
SHA256 bccaa8482d81c4ebb395b473d1e764ad44b6a6fc71624b28f07ee5c14447d689
MD5 81d4cb8387d54369c74b46d2732caeab
BLAKE2b-256 2caa10e3b80f8bcb093bd57786e018557c81f7eebca149ed77bed4b566640851

See more details on using hashes here.

File details

Details for the file sqbooster-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: sqbooster-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for sqbooster-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1767e4360ebbb7813b4666af2a3c01b4d72d8a1f16d2cb074fa5968c7cba8c8a
MD5 1be6071038d6cb524d073dfde0695740
BLAKE2b-256 dfe233094e7867b92681933bd8281f3ccaec86318b80c0b4776045c8c0a860f0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

1.0.0

2 files

0.1.3

2 files

0.0.2

2 files

0.0.1

2 files

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