Skip to main content

SiRQL is a simple language specification which defines the way how to receive and query data over an http request.

Project description

SiRQL (pronounced **ˈsɜːrkl**) is a simple language specification which defines the way how to receive and query data over an http request.

The goal of SiRQL is to provide a simple and human readable query text and the possibility to define query fields in swagger.

Implementations

Python

Latest Version Development Status Python Versions

pip install SiRQL

Definition 1.3

Example

This is a simple example of a SiRQL query which receives all the users which are called Florian and are happy.

http://example/users/find?name=eq("Florian")&is_happy=is(TRUE)

Conditions

SiRQL uses the uniform resource identifier (URI) specification to define queries and send them over http to the server.

Usually the REST protocol is used to serve the result and query the data.

baseurl/find?``condition1``&condition2&condition3

The conditions are combined with the AND operator:

condition1 AND condition2 AND condition3

Structure

A condition is always structured by following pattern:

field_name = operator(param1, param2, …)

name

description

resource_name

The resource field name which

operator

Read about operators in the next chapter

param1, param2, …

A parameter contains one value which will be used to query the data

Operators

Currently SiRQL supports following operators with these limitations:

  • Per query field only one operator can be used

  • Operators are not case sensitive

Less than (lt)

Compares the field value to the parameter and returns True if the field value is lower then the parameter.

http://example/data/find?age=lt(10)

Greater than (gt)

Compares the field value to the parameter and returns True if the field value is higher then the parameter.

http://example/data/find?age=gt(10)

Between (between)

Compares the field value to the parameters and returns True if the field value is higher than the first parameter and lower than the second parameter.

http://example/data/find?age=between(5, 10)

Equals to (eq)

Compares the field value to the parameters and returns True if the field value matches one of the parameters exactly.

Usually only one parameter is used:

http://example/data/find?name=eq("Florian")

It is possible to add multiple parameters which could match:

http://example/data/find?name=eq("Florian", "Manuel")

Results in a query like:

if name is "Florian" OR "Manuel"

Like (like)

Compares the field value to the parameter and returns True if the field value matches the parameter.

Wildcards like % can be used in the parameter string:

http://example/data/find?name=like("Flo%")

Is (is)

Returns True if the field value matches the given type.

http://example/data/find?name=is(NULL)
http://example/data/find?name=is(FALSE)
http://example/data/find?name=is(TRUE)

Negation (not)

To negate an operator it is possible to use not_ as operator prefix. With the not_ prefix the result of the expression will be negated.

This will match all values which are not Florian:

http://example/data/find?name=not_eq("Florian")

Other examples:

http://example/data/find?is_happy=not_is(True)
http://example/data/find?age=not_gt(10)
http://example/data/find?age=not_between(5, 10)

Contains (contains)

Returns True if the first parameter does exist in the field. This methods does only work for JSON fields.

http://example/data/find?data=contains("time")

String Parameter

To pass text as a parameter it is possible to use quotes ". In a string query reserved characters like =, (, ), , are automatically escaped. Usually this is used to compare text or query date-time.

http://example/data/find?comment=eq("hello, (world)")

String Escaping

 Quotes

To escape quotes in strings it is possible to use the backslash character \ in front of the quote sign ". With that it is possible to use quote signs in strings.

http://example/data/find?comment=eq("hello \"world\"")
Backslash

To escape a backslash \ it is possible to write a double–backlash which will be interpreted as one backslash.

http://example/data/find?comment=eq("hello \\ world")

About

Defined by i4Ds 2015

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

SiRQL-1.3.1.tar.gz (4.3 kB view hashes)

Uploaded Source

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