Skip to main content

link.dbrequest is a database agnostic query system.

See documentation for more informations.

License Development Status Latest release Supported Python versions Supported Python implementations Download format Build status Code test coverage Downloads Code Health

Installation

pip install link.dbrequest

Features

  • database agnostic

  • lazy query resolving

  • cached queries

  • queries are unique

Examples

Getting a backend:

from link.middleware.core import Middleware

# Will open a QueryManager using a MongoDB backend
manager = Middleware.get_middleware_by_uri('query+mongo://localhost:27107/mydatabase/mycollection')
# Will open a QueryManager using a SQL backend
manager = Middleware.get_middleware_by_uri('query+sql://localhost:5432/mydatabase/mytable')

Operations on the backend:

from link.dbrequest.expression import E, F
from link.dbrequest.assignment import A
from link.dbrequest.comparison import C


query = manager.all()  # get an iterable over all elements

manager.create(A('foo', 'bar'))  # put document {'foo': 'bar'} into database

doc = manager.get(C('foo') != 'bar')  # get single element, or None

Operations on queries:

docs = list(query)  # iterate over query to execute the request
docs = list(query)  # use cache when iterating again

# create a new query from the first one
q2 = query.filter(C('foo') == 'bar')
assert query is not q2

# exclude documents without a field named "bar"
q3 = q2.exclude(~C('bar'))

# filter documents "weight > 5" and "prop1 < prop2 * 5"
q4 = q3.filter((C('weight') > 5) & (C('prop1') < (E('prop2') * 5)))

# set "prop3 = prop1 + prop2" on q2 result
docs = q2.update(A('prop3', E('prop1') + E('prop2')))

# delete documents
q3.delete()

Operations on documents:

# save/delete a single document
doc.save()
doc.delete()

Donating

Support via Liberapay

Release files for link.dbrequest 0.19

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

Source distribution (sdist)

Source distribution for link.dbrequest 0.19
File Size Uploaded
link.dbrequest-0.19.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for link.dbrequest 0.19
File Interpreter ABI Platform
link.dbrequest-0.19-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 46.7 kB

Release files / link.dbrequest-0.19.tar.gz

Download URL link.dbrequest-0.19.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
313aae6c0b95d406b8e6b857c2b175f5a707e242db34689bbdff9485fcccc653
BLAKE2b-256 checksum
How to use checksums
1eb57fa6c92b4c18187d97c7ae4a73dac387fc1913519464c510edae6dee7245
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / link.dbrequest-0.19-py2.py3-none-any.whl

Download URL link.dbrequest-0.19-py2.py3-none-any.whl
Size 29.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
472d2b1f2835ce01210ccd5d8332867774c69de58587a751f4701a2f7a941e94
BLAKE2b-256 checksum
How to use checksums
8ff386cb63ed921c4efcb039b3c7d66eaca2622f5aef9532d9a94c026c26bf4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.19 This release

2 release files

0.18

2 release files

0.17

2 release files

0.16

2 release files

0.15

2 release files

0.14

2 release files

0.13

2 release files

0.12

2 release files

0.11

2 release files

0.10

2 release files

0.9

2 release files

0.8

1 release file

0.7

2 release files

0.5

1 release file

0.4

1 release file

0.3

2 release files

0.2

2 release files

0.1

2 release 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