Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

istSOS𝜇 protocol buffer repository.

This module contains all the proto files of istsos.

Qry Utils

Simple usage example

from istsosproto import qry

conditions = qry(
    {
        "value": "value_obs",
        "updated": "updated_obs"
    }
).get_conditions(
    Where(
        operator=Where.AND,
        where=[
            Where(
                operator=Where.GREATER_THAN,
                property='value',
                measure=2.0
            ),
            Where(
                operator=Where.NOT_NULL,
                property='updated'
            )
        ]
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

('(value_obs > $1 AND updated_obs IS NOT NULL)', [2.0])

Comparison operators

Supported operators:

  • NULL
  • NOT_NULL
  • EQUALS
  • NOT_EQUALS
  • LIKE
  • GREATER_THAN
  • GREATER_THAN_OR_EQUAL_TO
  • LESS_THAN
  • LESS_THAN_OR_EQUAL_TO

NULL

Where(
    operator=Where.NULL,
    property='updated'
)

result:

(
    "updated IS NULL",
    []
)

NOT_NULL

Where(
    operator=Where.EQUALS,
    property='updated'
)

result:

(
    "updated IS NOT NULL",
    []
)

EQUALS

Where(
    operator=Where.EQUALS,
    property='value',
    mesaure=10.9
)

result:

(
    "value = $1",
    [10.9]
)

NOT_EQUALS

Where(
    operator=Where.NOT_EQUALS,
    property='value',
    mesaure=10.9
)

result:

(
    "value <> $1",
    [10.9]
)

LIKE

Where(
    operator=Where.LIKE,
    property='name',
    text='%foo'
)

result:

(
    "name IS LIKE $1",
    ['%foo]
)

Usage with function

Supported functions are:

  • STARTS_WITH
  • ST_INTERSECTS
  • ST_DWITHIN
  • ST_CONTAINS

INTERSECTS

from qry import *

conditions = qry(
    {
        "geom": "geom_loc"
    }
).get_conditions(
    Where(
        function=Where.ST_INTERSECTS,
        property='geom',
        ewkt='SRID=4326;BOX(-180 -90, 180 90)'
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

(
    "ST_Intersects(geom_loc, ST_GeomFromEWKT($1))",
    ['SRID=4326;BOX(-180 -90, 180 90)']
)

DWITHIN

from qry import *

conditions = qry(
    {
        "geom": "geom_loc"
    }
).get_conditions(
    Where(
        function=Where.ST_DWITHIN,
        property='geom',
        ewkt='SRID=3857;POINT(3072163.4 7159374.1)',
        xmeasure=200
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

(
    "ST_DWithin(geom_loc, ST_GeomFromEWKT($1), $2)",
    ['SRID=4326;BOX(-180 -90, 180 90)', 200]
)

CONTAINS

from qry import *

conditions = qry(
    {
        "geom": "geom_loc"
    }
).get_conditions(
    Where(
        function=Where.ST_CONTAINS,
        property='geom',
        ewkt='SRID=3857;POINT(3072163.4 7159374.1)',
        xmeasure=200
    )
)

print(conditions)

get_conditions call returns a tuple with the SQL and a list of parameters:

(
    "ST_Contains(geom_loc, ST_GeomFromEWKT($1))",
    ['SRID=3857;POINT(3072163.4 7159374.1)']
)

Release files for istsos-proto 0.0.1b3

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

Source distribution (sdist)

Source distribution for istsos-proto 0.0.1b3
File Size Uploaded
istsos-proto-0.0.1b3.tar.gz 15.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for istsos-proto 0.0.1b3
File Interpreter ABI Platform
istsos_proto-0.0.1b3-py3-none-any.whl Python 3 none any Details

Total release size: 36.6 kB

Release files / istsos-proto-0.0.1b3.tar.gz

Download URL istsos-proto-0.0.1b3.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b3d1a52908c4c611fa8796b2edce4146f627558da3fd35a36ced04b9c5a1fe52
BLAKE2b-256 checksum
How to use checksums
7e6c0c75f1f434e03dc3c5e6423c5e2ef16e1b908592f75a3f67ef801c6e9a1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / istsos_proto-0.0.1b3-py3-none-any.whl

Download URL istsos_proto-0.0.1b3-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4d245aebe4ab0d84f9a4f6c27b4c096810225409514384fdda968724394ac4d
BLAKE2b-256 checksum
How to use checksums
608040711b7b3313d6516cde6caeaea7e7fb06d121b1c17397db403ba8825d4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.1b3 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