Skip to main content

A Python Redis ORM

Project description

Status

pypi package total downloads deploy docs

Documentation: popoto.io

Popoto - A Redis/Valkey ORM (Object-Relational Mapper)

Install

pip install popoto

Running

Popoto is a library, not a standalone service. It runs inside your application and talks to a Redis or Valkey server. To exercise it locally (and to run the test suite) you need a Redis/Valkey server listening on localhost:6379.

# 1. Start Redis (or Valkey), e.g. on macOS via Homebrew:
redis-server                     # or: brew services start redis

# 2. Install Popoto with dev dependencies:
uv venv && source .venv/bin/activate && uv pip install -e ".[dev]"

# 3. Run the test suite (auto-isolated on Redis DB 15):
pytest

By default Popoto connects to localhost:6379; set REDIS_URL to point at a different server. The pytest plugin isolates tests on Redis DB 15 (override with POPOTO_TEST_DB=<n>).

Basic Usage

from popoto import Model, KeyField, Field, SortedField

class Restaurant(Model):
    name = KeyField()
    cuisine = Field()
    rating = SortedField(type=float)

Restaurant.create(name="Burger Palace", cuisine="American", rating=4.5)

restaurant = Restaurant.query.get(name="Burger Palace")

print(f"{restaurant.name} serves {restaurant.cuisine} food.")
# => "Burger Palace serves American food."

Popoto Features

  • very fast stores and queries
  • familiar syntax, similar to Django models
  • Async operations for asyncio-based applications
  • Geometric distance search
  • Timeseries for streaming data
  • compatible with Pandas, Xarray for N-dimensional matrix search
  • PubSub for message queues, streaming data processing
  • Full Redis and Valkey support - works with both out of the box
  • Agent Memory - programmable memory primitives for AI agents (decay, confidence, associations, context assembly)
  • Content & Embeddings - large content storage, vector embeddings, and semantic search

Popoto is ideal for streaming data. The pub/sub module allows you to trigger state updates in real time. Currently being used in production for:

  • trigger buy/sell actions from streaming price data
  • robots sending each other messages for teamwork
  • compressing sensor data and training neural networks

Advanced Usage

import popoto
from popoto import Relationship, DatetimeField

class Restaurant(popoto.Model):
    name = popoto.KeyField()
    cuisine = popoto.Field()
    rating = popoto.SortedField(type=float)
    location = popoto.GeoField()

class Order(popoto.Model):
    order_id = popoto.AutoKeyField()
    restaurant = Relationship(Restaurant)
    total = popoto.SortedField(type=float)
    status = popoto.Field(default="pending")
    created_at = DatetimeField(auto_now_add=True)

    class Meta:
        order_by = "-created_at"
        ttl = 2592000  # 30 days

Save Instances

restaurant = Restaurant(name="Burger Palace")
restaurant.cuisine = "American"
restaurant.rating = 4.5
restaurant.location = (40.7128, -74.0060)
restaurant.save()

order = Order.create(restaurant=restaurant, total=24.99)

Queries

from datetime import datetime, timedelta

midtown = (40.7549, -73.9840)
yesterday = datetime.now() - timedelta(days=1)

nearby_restaurants = Restaurant.query.filter(
    location=midtown,
    location_radius=5, location_radius_unit='km',
    rating__gte=4.0
)

print(len(nearby_restaurants))
# => 1

recent_orders = Order.query.filter(
    created_at__gte=yesterday,
    total__gte=10.00
)

Documentation

Documentation is available at popoto.io

Please create new feature and documentation related issues github.com/tomcounsell/popoto/issues or make a pull request with your improvements.

License

Popoto ORM is released under the MIT Open Source license.

Popoto Community

Questions, bug reports, and feature requests are welcome on GitHub Issues and GitHub Discussions. Contributions via pull request are encouraged.

Popoto gets its name from the Maui dolphin subspecies - the world's smallest dolphin subspecies. Because dolphins are fast moving, agile, and work together in social groups. In the same way, Popoto wraps Redis and Valkey to make it easy to manage streaming timeseries data and object persistence.

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

popoto-1.8.0.tar.gz (560.9 kB view details)

Uploaded Source

Built Distribution

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

popoto-1.8.0-py3-none-any.whl (318.5 kB view details)

Uploaded Python 3

File details

Details for the file popoto-1.8.0.tar.gz.

File metadata

  • Download URL: popoto-1.8.0.tar.gz
  • Upload date:
  • Size: 560.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for popoto-1.8.0.tar.gz
Algorithm Hash digest
SHA256 e2f2beb93f724d527c86293e16e08b8d94f70ad472ab09db7d7ef483364dba1e
MD5 bf5ddc30ea95bc81649ceeaab3cef96d
BLAKE2b-256 3cf018a8619fb3af8fa8ec13056d13e8502dab5820fb99b710c06050582dec14

See more details on using hashes here.

Provenance

The following attestation bundles were made for popoto-1.8.0.tar.gz:

Publisher: release.yml on tomcounsell/popoto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file popoto-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: popoto-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 318.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for popoto-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1aaa2d17380ac88b1342df7baec37503b3f79223b20548efe7d629ebe79dc31d
MD5 f5cd203cc7933abcf91325f44ea7b042
BLAKE2b-256 cfa741cd8d7ae9c4014d59fdad8ca40ba63ef57be97311b1ea2a33deb2746da3

See more details on using hashes here.

Provenance

The following attestation bundles were made for popoto-1.8.0-py3-none-any.whl:

Publisher: release.yml on tomcounsell/popoto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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