Skip to main content

SQC

SQL Queries to Collections

Examples

from sqc import sqc

data = [
    {"a": 1, "b": 1},
    {"a": 2, "b": 1},
    {"a": 3, "b": 2},
]

Simple filtering

query = sqc("SELECT b WHERE a = 2")
reset = query.execute(data)
assert result == [{"b": 1}]

Roadmap:

Named data source:

query = sqc("SELECT b FROM table WHERE a < 2")
reset = query.execute(table=data)
assert result == [{"b": 1}]

Attribute access:

from typing import NamedTuple

class Row(NamedTuple):
    a: int
    b: int

query = sqc("SELECT b WHERE a < 2", field_getter=getattr)
assert isinstance(query, SqcQuery)
reset = query.execute(map(Row._make, data))
assert result == [{"b": 1}]

Nested data structures:

query = sqc("SELECT path(a, 'c[a].b[0]') AS q, c WHERE b > 1")

Custom output structure:

query = sqc("SELECT b WHERE a < 2", output=tuple)
reset = query.execute(data)
assert result == [(1,)]

Shortcuts:

query = sqc("SELECT b WHERE a < 2")
assert query.one(data) = (1,)
assert query.scalar(data) == 1

Metadata

Release files for sqc 0.1.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 sqc 0.1.0
File Size Uploaded
sqc-0.1.0.tar.gz 3.3 kB Details

Built distribution (wheel)

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

Total release size: 6.7 kB

Release files / sqc-0.1.0.tar.gz

Download URL sqc-0.1.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d2f22aa0b06babcf322fc656b3ab195a5796cd5ceda5621a391fe27f5101afcc
BLAKE2b-256 checksum
How to use checksums
068558cad4ee02044ef9a1dea1f0a1e59bf4ca3c02750710d3b61440686c145c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release files / sqc-0.1.0-py2.py3-none-any.whl

Download URL sqc-0.1.0-py2.py3-none-any.whl
Size 3.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ca261927ece519566801ccb589e19c0eab42c60f447693b1271794facefba23d
BLAKE2b-256 checksum
How to use checksums
21257a9d5cad9054017ac924dc151c07b9311efdd11fae19bcc2844bbdb83a41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.26.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

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