Querying

A package for objects in Python and mapping them to QuickBase-expected JSON.

QueryBase

class quickbase_client.QuickBaseQuery(where, options=None, group_by=None, sort_by=None, select=None)

A base object for all of the data for a query.

Variables

where – The where string, e.g. "{7.EX.'18'}"


AST Query Building Methods

This module includes functions which create QuickBaseQuery objects.

These can be assembled in an AST-like fashion to build a complex query using higher-level english-readable functions rather than going through the query language (note you can always create a QuickBaseQuery and provide the where string to use that).

Example:

schema = MyTable.schema
my_query = and_(
    eq_(schema.date_opened, schema.date_created),
    on_or_before_(schema.date_closed, date(2020, 11, 16))
)
print(my_query.where) # ({'9'.EX.'_FID_1'}AND{'10'.OBF.'11-16-2020'})

All of the methods (except the two conjunction ones), take a QuickBaseField and a value as a parameter. If you pass a QuickBaseField for the value, it will compare to the actual field (see above). But note if you pass an attribute of a QuickBaseTable class it would be the value in memory of that attribute. If you want to compare to the actual field, use the schema property of the table or quickbase_client.QuickBaseTable.get_field_info().

Note all of these methods are named with a trailing _ to maintain consistency and never clash with a python keyword or anything.

quickbase_client.query.or_(*clauses)

Conjunction to join 2 or more logical OR’s.

quickbase_client.query.and_(*clauses)

Conjunction to join 2 or more logical AND’s.

quickbase_client.query.contains_(field, val)

Contains (CT).

quickbase_client.query.not_contains_(field, val)

Not Contains (XCT).

quickbase_client.query.has_(field, val)

Has (HAS).

quickbase_client.query.not_has_(field, val)

Not Has (XHAS).

quickbase_client.query.eq_(field, val)

Equal/Exactly (EX).

quickbase_client.query.not_eq_(field, val)

Not Equal (XEX).

quickbase_client.query.starts_with_(field, val)

Starts With (SW).

quickbase_client.query.not_starts_width_(field, val)

Not Starts With (XSW).

quickbase_client.query.before_(field, val)

Before (BF).

quickbase_client.query.on_or_before_(field, val)

On or Before (OBF).

quickbase_client.query.after_(field, val)

After (AF).

quickbase_client.query.on_or_after_(field, val)

On or After (OAF).

quickbase_client.query.during_(field, val)

During (IR).

quickbase_client.query.not_during_(field, val)

Not During (XIR).

quickbase_client.query.lt_(field, val)

Less than (LT).

quickbase_client.query.lte_(field, val)

Less than or Equal (LTE).

quickbase_client.query.gt_(field, val)

Greater than (GT).

quickbase_client.query.gte_(field, val)

Greater than or Equal (GTE).