flywheel.query module

Query and Scan builders

class flywheel.query.Query(engine, model)[source]

Bases: object

An object used to query dynamo tables

See the Engine for query examples

Parameters:

engine : Engine

model : class

Subclass of Model

all(desc=False, consistent=False, attributes=None)[source]

Return the query results as a list

Parameters:

desc : bool, optional

Return results in descending order (default False)

consistent : bool, optional

Force a consistent read of the data (default False)

attributes : list, optional

List of fields to retrieve from dynamo. If supplied, returns boto ResultItems instead of model objects.

delete()[source]

Delete all items that match the query

filter(*conditions, **kwargs)[source]

Add a Condition to constrain the query

Notes

The conditions may be passed in as positional arguments:

engine.query(User).filter(User.id == 12345)

Or they may be passed in as keyword arguments:

engine.query(User).filter(firstname='Monty', lastname='Python')

The limitations of the keyword method is that you may only create equality conditions. You may use both types in a single filter:

engine.query(User).filter(User.num_friends > 10, name='Monty')
first(desc=False, consistent=False, attributes=None)[source]

Return the first result of the query, or None if no results

Parameters:

desc : bool, optional

Return results in descending order (default False)

consistent : bool, optional

Force a consistent read of the data (default False)

attributes : list, optional

List of fields to retrieve from dynamo. If supplied, returns boto ResultItems instead of model objects.

gen(desc=False, consistent=False, attributes=None)[source]

Return the query results as a generator

Parameters:

desc : bool, optional

Return results in descending order (default False)

consistent : bool, optional

Force a consistent read of the data (default False)

attributes : list, optional

List of fields to retrieve from dynamo. If supplied, gen() will iterate over boto ResultItems instead of model objects.

index(name)[source]

Use a specific local or global index for the query

limit(count)[source]

Limit the number of query results

one(consistent=False, attributes=None)[source]

Return the result of the query. If there is not exactly one result, raise a ValueError

Parameters:

consistent : bool, optional

Force a consistent read of the data (default False)

attributes : list, optional

List of fields to retrieve from dynamo. If supplied, returns boto ResultItems instead of model objects.

Raises:

exc : ValueError

If there is not exactly one result

table[source]

Shortcut to access dynamo table

class flywheel.query.Scan(engine, model)[source]

Bases: flywheel.query.Query

An object used to scan dynamo tables

scans are like Queries except they don’t use indexes. This means they iterate over all data in the table and are SLOW

Parameters:

engine : Engine

model : class

Subclass of Model

gen(attributes=None, desc=False, consistent=False)[source]
index(name)[source]
Read the Docs v: 0.1.3
Versions
latest
0.1.3
0.1.2
0.1.1
0.1.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.