Skip to main content

Python library for managing and persisting named Python Queues with a variety of backend choices

Project description

dq

A python library for managing and persisting named Python Queues

Installation

pip install pydq

Some backends may require extra packages:

pip install pydq[aws]

Basic Usage

with dq_provider('name') as dq:
    # Query the last 10 entries with qid='item_id'
    dq(qid='item_id', start_time=datetime(1, 1, 1), end_time=datetime.utcnow(), limit=10)
    item = dq.get()
    # queue items should be dictionaries with 3 keys: qid, ts, and val
    dq.put({'qid': 'item_id', 'ts': '2019-09-11T03:23:54Z', 'val': 'foo'})

note: specifying qid in the query is optional, if omitted all items between the start and end time are returned

Supported Backends:

Local Storage

  • SQLite:
from dq.local import SQLite as dq_provider

Cloud Storage

  • Buffered DynamoDB
from dq.cloud import BufferedDDB as dq_provider

note: cloud storage is created lazily; the first call to one of these providers will create the resources in the cloud.

Additional API

Some queue methods accept a forget argument that will tell the queue object whether the operation should be persisted. This always defaults to False.

dq.get(forget=True)  # the returned item will be deleted from persistence
dq.put(item, forget=True)    # item will not be persisted
dq.get_all(forget=True)  # Easy way to delete all items in a queue
dq.put_all(items, forget=False)
dq.get_to_dataframe()    # install with pandas extra. Returned items are not deleted
dq.put_from_dataframe(df)    # items will be persisted
dq.clear(forget=True)    # another way to delete all items in a queue

Configuration queues

dq is great for managing simple JSON configuration too. And we get change tracking for free!

from dq.helpers import DqConfig
from dq.local import SQLite
with DqConfig(name='ApplicationConfig', dq_provider=SQLite) as config:
    app_id = config['app_id']
    last_start = config['last_start']
    config['app_status'] = '#1best'

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pydq-0.1.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file pydq-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pydq-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.2

File hashes

Hashes for pydq-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 17a23a5c819b13a904ee5ec827e56f496598d024100896d7c1c66729a0f5afea
MD5 a209c7b24fd2eae29541765d6a11c550
BLAKE2b-256 b101ab1c5047bafd3aa088af5fd54d2fc4bbb45424f20cc7931b5dae41457c2e

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