tori.db.driver

class tori.db.driver.interface.DialectInterface

Dialect interface

It is used to translate a generic query into a native query.

get_alias_to_native_query_map(query)

Retrieve a map from alias to native query.

Parameters:tori.db.criteria.Query – the query object
Return type:dict
get_iterating_constrains(query)

Retrieve the query constrains.

Raises:NotImplemented – only if the interface is not overridden.
get_native_operand(generic_operand)

Translate a generic operand into a corresponding native operand.

Parameters:generic_operand – a generic operand
Returns:a native operand
Return type:str
process_join_conditions(alias_to_conditions_map, alias, join_config, parent_alias)

Process the join conditions.

Parameters:
  • alias_to_conditions_map (dict) – a alias-to-conditions map
  • join_config (dict) – a join config map
  • alias (str) – an alias of the given join map
  • parent_alias (str) – the parent alias of the given join map
Raises:

NotImplemented – only if the interface is not overridden.

process_non_join_conditions(alias_to_conditions_map, definition_map, left, right, operand)

Process the non-join conditions.

Parameters:
Raises:

NotImplemented – only if the interface is not overridden.

class tori.db.driver.interface.DriverInterface(config, dialect)

The abstract driver interface

Parameters:
client

Driver Connection / Client

collection(name)

Low-level Collection-class API

Returns:the low-level collection-class API
Raises:NotImplemented – only if the interface is not overridden.
config

Driver configuration

connect(config)

Connect the client to the server.

Raises:NotImplemented – only if the interface is not overridden.
database_name

The name of provisioned database

db(name)

Low-level Database-class API

Returns:the low-level database-class API
Raises:NotImplemented – only if the interface is not overridden.
dialect

Driver dialect

disconnect()

Disconnect the client.

Raises:NotImplemented – only if the interface is not overridden.
index_count()

Retrieve the number of indexes.

Raises:NotImplemented – only if the interface is not overridden.
indice()

Retrieve the indice.

Raises:NotImplemented – only if the interface is not overridden.
insert(collection_name, data)

Low-level insert function

Raises:NotImplemented – only if the interface is not overridden.
class tori.db.driver.interface.QueryIteration(alias, native_query)

Driver Query Iteration

This is a metadata class representing an iteration in complex queries.

Parameters:
  • alias (str) – the alias of the rewritten target
  • native_query (dict) – the native query for a specific engine

Note

Internal use only

class tori.db.driver.interface.QuerySequence

Driver Query Sequence

The collection represents the sequence of sub queries.

add(iteration)

Append the the iteration

Parameters:iteration (tori.db.driver.interface.QueryIteration) – the query iteration
each()

Get the sequence iterator.

exception tori.db.driver.mongodriver.InvalidExpressionError

MongoDB-specific Invalid Expression Error

exception tori.db.driver.mongodriver.UnsupportedExpressionError

MongoDB-specific Unsupported Expression Error

This is due to that the expression may be unsafe (e.g., 1 = 2) or result in unnecessary complex computation (e.g., e.mobile_phone = e.home_phone).