YAML parser for sqla-filters.
Project description
Sqla-filters-yaml
Add yaml parser to the sqla-filters package.
Introduction
Add YAML support to sqla-filters.
Requirements
This package use the python package pyyaml
. To install pyyaml you need to have the yaml.h header file. If it's not
present on your system you need to install the libyaml-dev package.
- On Fedora
sudo dnf install libyaml-devel
- On Debian based distribution (Ubuntu, ...)
sudo apt install libyaml-dev
Installation
pip install sqla-filter-yaml
Getting Started
YAML format
---
type: and
data:
- type: or
data:
- type: operator
data:
attribute: name
operator: eq
value: toto
- type: operator
data:
attribute: name
operator: eq
value: tata
- type: operator
data:
attribute: age
operator: eq
value: 21
:warning: Yaml format can change in the futur. :warning:
Example code
Create an instance of the YAMLilterParser from the yaml string / document.
Example:
# Sqlalchemy setup + model definition
# Create a YAML parser instance
parser = YAMLiltersParser(raw_json_string)
# You can finaly filter your query
query = session.query(Post)
filtered_query = parser.tree.filter(query)
# Get the results
query.all()
Result tree
+----------------------+
| |
| and |
| |
-----------------------+
||
||
||
+----------------------+ || +----------------------+
| | || | |
| or <------------> age == 21 |
| | | |
+----------------------+ +----------------------+
||
||
||
+----------------------+ || +----------------------+
| | || | |
| name == toto <----------------> name == tata |
| | | |
+----------------------+ +----------------------+
Contribute
Fork the repository and run the following command to install the dependencies and the dev dependencies.
pip install -e '.[dev]'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sqla_filters_yaml-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a575b24c45f7bd745d9e1d4b191205e311493f35b7543f0084294b8d4cc85cf |
|
MD5 | a560624ec56a848f9601830e1d0f2701 |
|
BLAKE2b-256 | f784312220ba7db87e0277e9890f8e854865f78011712a1e466a26647ab05573 |