privex.db.query.sqlite

Classes

SqliteQueryBuilder(table[, connection])

class privex.db.query.sqlite.SqliteQueryBuilder(table: str, connection: privex.db.types.GenericConnection = None, **kwargs)[source]
all(query_mode=<QueryMode.ROW_DICT: 'dict'>) → Union[Iterable[dict], Iterable[tuple]][source]

Executes the current query, and returns an iterable cursor (results are loaded as you iterate the cursor)

Usage:

>>> results = BaseQueryBuilder('people').all()   # Equivalent to ``SELECT * FROM people;``
>>> for r in results:
>>>     print(r['first_name'], r['last_name'], r['phone'])
Return Iterable

A cursor which can be iterated using a for loop. Ideally, should load rows as you iterate, saving RAM.

build_query() → str[source]

Used internally by all() and fetch() - builds and returns a string SQL query using the various class attributes such as where_clauses :return str query: The SQL query that will be sent to the database as a string

fetch(query_mode=<QueryMode.ROW_DICT: 'dict'>) → Union[dict, tuple, None][source]

Executes the current query, and fetches the first result as a dict.

If there are no results, will return None

Return dict

The query result as a dictionary: {column: value, }

Return None

If no results are found

fetch_next(query_mode=<QueryMode.ROW_DICT: 'dict'>) → Union[dict, tuple, None][source]

Similar to fetch(), but doesn’t close the cursor after the query, so can be ran more than once to iterate row-by-row over the results.

Parameters

query_mode (QueryMode) –

Returns