How to use the tinydb.queries.where function in tinydb

To help you get started, we’ve selected a few tinydb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github msiemens / tinydb / tests / tests_queries.py View on Github external
def test_gt():
    query = where('value') > 1
    assert_true(query({'value': 2}))
    assert_false(query({'value': 1}))
github msiemens / tinydb / tests / tests_queries.py View on Github external
def test_has_key():
    query = where('val3')

    assert_true(query({'val3': 1}))
    assert_false(query({'val1': 1, 'val2': 2}))
github msiemens / tinydb / tests / tests_queries.py View on Github external
def test_le():
    query = where('value') <= 1
    assert_true(query({'value': 0}))
    assert_true(query({'value': 1}))
    assert_false(query({'value': 2}))
github msiemens / tinydb / tests / tests_queries.py View on Github external
def test_not():
    query = ~ (where('val1') == 1)
    assert_true(query({'val1': 5, 'val2': 2}))
    assert_false(query({'val1': 1, 'val2': 2}))

    query = (
        (~ (where('val1') == 1)) &
        (where('val2') == 2)
    )
    assert_true(query({'val1': '', 'val2': 2}))
    assert_true(query({'val2': 2}))
    assert_false(query({'val1': 1, 'val2': 2}))
    assert_false(query({'val1': 1}))
    assert_false(query({'val1': '', 'val2': ''}))
github msiemens / tinydb / tests / tests_queries.py View on Github external
def test_ge():
    query = where('value') >= 1
    assert_true(query({'value': 2}))
    assert_true(query({'value': 1}))
    assert_false(query({'value': 0}))
github msiemens / tinydb / tests / tests_queries.py View on Github external
def test_ne():
    query = where('value') != 1
    assert_true(query({'value': 2}))
    assert_false(query({'value': 1}))
github msiemens / tinydb / tests / tests_queries.py View on Github external
def test_not():
    query = ~ (where('val1') == 1)
    assert_true(query({'val1': 5, 'val2': 2}))
    assert_false(query({'val1': 1, 'val2': 2}))

    query = (
        (~ (where('val1') == 1)) &
        (where('val2') == 2)
    )
    assert_true(query({'val1': '', 'val2': 2}))
    assert_true(query({'val2': 2}))
    assert_false(query({'val1': 1, 'val2': 2}))
    assert_false(query({'val1': 1}))
    assert_false(query({'val1': '', 'val2': ''}))
github marcwebbie / passpie / passpie / interface / cli.py View on Github external
def search(regex):
    db = Database(config.path)
    credentials = db.search(
        where("name").matches(regex) |
        where("login").matches(regex) |
        where("comment").matches(regex))
    credentials = sorted(credentials, key=lambda x: x["name"]+x["login"])

    if credentials:
        click.echo(make_table(credentials))
github marcwebbie / passpie / passpie / interface / cli.py View on Github external
def search(regex):
    db = Database(config.path)
    credentials = db.search(
        where("name").matches(regex) |
        where("login").matches(regex) |
        where("comment").matches(regex))
    credentials = sorted(credentials, key=lambda x: x["name"]+x["login"])

    if credentials:
        click.echo(make_table(credentials))
github marcwebbie / passpie / passpie / interface / cli.py View on Github external
def search(regex):
    db = Database(config.path)
    credentials = db.search(
        where("name").matches(regex) |
        where("login").matches(regex) |
        where("comment").matches(regex))
    credentials = sorted(credentials, key=lambda x: x["name"]+x["login"])

    if credentials:
        click.echo(make_table(credentials))