Skip to main content

Module containing all istsos compiled proto files.

Project description

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)']
)

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

istsos-proto-0.0.1b3.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

istsos_proto-0.0.1b3-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file istsos-proto-0.0.1b3.tar.gz.

File metadata

  • Download URL: istsos-proto-0.0.1b3.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for istsos-proto-0.0.1b3.tar.gz
Algorithm Hash digest
SHA256 b3d1a52908c4c611fa8796b2edce4146f627558da3fd35a36ced04b9c5a1fe52
MD5 0334a154caee6bd334039573d1a63c40
BLAKE2b-256 7e6c0c75f1f434e03dc3c5e6423c5e2ef16e1b908592f75a3f67ef801c6e9a1d

See more details on using hashes here.

File details

Details for the file istsos_proto-0.0.1b3-py3-none-any.whl.

File metadata

  • Download URL: istsos_proto-0.0.1b3-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for istsos_proto-0.0.1b3-py3-none-any.whl
Algorithm Hash digest
SHA256 b4d245aebe4ab0d84f9a4f6c27b4c096810225409514384fdda968724394ac4d
MD5 9ba350dfd31c589348d3f57816ba744a
BLAKE2b-256 608040711b7b3313d6516cde6caeaea7e7fb06d121b1c17397db403ba8825d4d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page