class documentation

Default implementation of :class:`.Compiled`. Compiles :class:`_expression.ClauseElement` objects into SQL strings.

Method __init__ Construct a new :class:`.SQLCompiler` object.
Method bindparam_string Undocumented
Method construct_expanded_state Return a new :class:`.ExpandedState` for a given parameter set.
Method construct_params return a dictionary of bind parameter keys and values
Method default_from Called when a SELECT statement has no froms, and no FROM clause is to be appended.
Method delete_extra_from_clause Provide a hook to override the generation of an DELETE..FROM clause.
Method delete_table_clause Undocumented
Method escape_literal_column Undocumented
Method fetch_clause Undocumented
Method for_update_clause Undocumented
Method format_from_hint_text Undocumented
Method function_argspec Undocumented
Method get_crud_hint_text Undocumented
Method get_cte_preamble Undocumented
Method get_from_hint_text Undocumented
Method get_render_as_alias_suffix Undocumented
Method get_select_hint_text Undocumented
Method get_select_precolumns Called when building a ``SELECT`` statement, position is just before column list.
Method get_statement_hint_text Undocumented
Method group_by_clause allow dialects to customize how GROUP BY is rendered.
Method is_subquery Undocumented
Method limit_clause Undocumented
Method order_by_clause allow dialects to customize how ORDER BY is rendered.
Method post_process_text Undocumented
Method render_bind_cast Undocumented
Method render_literal_bindparam Undocumented
Method render_literal_value Render the value of a bind parameter as a quoted literal.
Method returning_clause Undocumented
Method update_from_clause Provide a hook to override the generation of an UPDATE..FROM clause.
Method update_limit_clause Provide a hook for MySQL to add LIMIT to the UPDATE
Method update_tables_clause Provide a hook to override the initial table clause in an UPDATE statement.
Method visit_alias Undocumented
Method visit_between_op_binary Undocumented
Method visit_binary Undocumented
Method visit_bindparam Undocumented
Method visit_case Undocumented
Method visit_cast Undocumented
Method visit_clauselist Undocumented
Method visit_collation Undocumented
Method visit_column Undocumented
Method visit_compound_select Undocumented
Method visit_contains_op_binary Undocumented
Method visit_cte Undocumented
Method visit_custom_op_binary Undocumented
Method visit_custom_op_unary_modifier Undocumented
Method visit_custom_op_unary_operator Undocumented
Method visit_delete Undocumented
Method visit_empty_set_expr Undocumented
Method visit_empty_set_op_expr Undocumented
Method visit_endswith_op_binary Undocumented
Method visit_expression_clauselist Undocumented
Method visit_extract Undocumented
Method visit_false Undocumented
Method visit_floordiv_binary Undocumented
Method visit_fromclause Undocumented
Method visit_funcfilter Undocumented
Method visit_function Undocumented
Method visit_function_as_comparison_op_binary Undocumented
Method visit_grouping Undocumented
Method visit_icontains_op_binary Undocumented
Method visit_iendswith_op_binary Undocumented
Method visit_ilike_case_insensitive_operand Undocumented
Method visit_ilike_op_binary Undocumented
Method visit_index Undocumented
Method visit_insert Undocumented
Method visit_is_false_unary_operator Undocumented
Method visit_is_true_unary_operator Undocumented
Method visit_istartswith_op_binary Undocumented
Method visit_join Undocumented
Method visit_label Undocumented
Method visit_label_reference Undocumented
Method visit_lambda_element Undocumented
Method visit_lateral Undocumented
Method visit_like_op_binary Undocumented
Method visit_mod_binary Undocumented
Method visit_next_value_func Undocumented
Method visit_not_between_op_binary Undocumented
Method visit_not_contains_op_binary Undocumented
Method visit_not_endswith_op_binary Undocumented
Method visit_not_icontains_op_binary Undocumented
Method visit_not_iendswith_op_binary Undocumented
Method visit_not_ilike_op_binary Undocumented
Method visit_not_in_op_binary Undocumented
Method visit_not_istartswith_op_binary Undocumented
Method visit_not_like_op_binary Undocumented
Method visit_not_match_op_binary Undocumented
Method visit_not_regexp_match_op_binary Undocumented
Method visit_not_startswith_op_binary Undocumented
Method visit_null Undocumented
Method visit_over Undocumented
Method visit_regexp_match_op_binary Undocumented
Method visit_regexp_replace_op_binary Undocumented
Method visit_release_savepoint Undocumented
Method visit_rollback_to_savepoint Undocumented
Method visit_savepoint Undocumented
Method visit_scalar_function_column Undocumented
Method visit_scalar_values Undocumented
Method visit_select Undocumented
Method visit_select_statement_grouping Undocumented
Method visit_sequence Undocumented
Method visit_startswith_op_binary Undocumented
Method visit_subquery Undocumented
Method visit_table Undocumented
Method visit_table_valued_alias Undocumented
Method visit_table_valued_column Undocumented
Method visit_tablesample Undocumented
Method visit_textclause Undocumented
Method visit_textual_label_reference Undocumented
Method visit_textual_select Undocumented
Method visit_true Undocumented
Method visit_truediv_binary Undocumented
Method visit_tuple Undocumented
Method visit_type_coerce Undocumented
Method visit_typeclause Undocumented
Method visit_unary Undocumented
Method visit_update Undocumented
Method visit_values Undocumented
Method visit_withingroup Undocumented
Class Variable ansi_bind_rules SQL 92 doesn't allow bind parameters to be used in the columns clause of a SELECT, nor does it allow ambiguous expressions like "? = ?". A compiler subclass can set this flag to False if the target driver/DB enforces this...
Class Variable bindname_escape_characters A mapping (e.g. dict or similar) containing a lookup of characters keyed to replacement characters which will be applied to all 'bind names' used in SQL statements as a form of 'escaping'; the given characters are replaced entirely with the 'replacement' character when rendered in the SQL statement, and a similar translation is performed on the incoming names used in parameter dictionaries passed to methods like :meth:`_engine...
Class Variable implicit_returning list of "implicit" returning columns for a toplevel INSERT or UPDATE statement, used to receive newly generated values of columns.
Class Variable insert_prefetch list of columns for which default values should be evaluated before an INSERT takes place
Class Variable is_sql Undocumented
Class Variable literal_execute_params bindparameter objects that are rendered as literal values at statement execution time.
Class Variable post_compile_params bindparameter objects that are rendered as bound parameter placeholders at statement execution time.
Class Variable postfetch list of columns that can be post-fetched after INSERT or UPDATE to receive server-updated values
Class Variable postfetch_lastrowid if True, and this in insert, use cursor.lastrowid to populate result.inserted_primary_key.
Class Variable render_table_with_column_in_update_from set to True classwide to indicate the SET clause in a multi-table UPDATE statement should qualify columns with the table name (i.e. MySQL only)
Class Variable returning_precedes_values set to True classwide to generate RETURNING clauses before the VALUES or WHERE clause (i.e. MSSQL)
Class Variable translate_select_structure if not ``None``, should be a callable which accepts ``(select_stmt, **kw)`` and returns a select object. this is used for structural changes mostly to accommodate for LIMIT/OFFSET schemes
Class Variable update_prefetch list of columns for which onupdate default values should be evaluated before an UPDATE takes place
Instance Variable anon_map Undocumented
Instance Variable bind_names a dictionary of BindParameter instances to "compiled" names that are actually present in the generated SQL
Instance Variable binds a dictionary of bind parameter keys to BindParameter instances.
Instance Variable bindtemplate template to render bound parameters based on paramstyle.
Instance Variable cache_key The :class:`.CacheKey` that was generated ahead of creating this :class:`.Compiled` object.
Instance Variable column_keys Undocumented
Instance Variable compilation_bindtemplate template used by compiler to render parameters before positional paramstyle application
Instance Variable compile_state Optional :class:`.CompileState` object that maintains additional state used by the compiler.
Instance Variable ctes Undocumented
Instance Variable ctes_by_level_name Undocumented
Instance Variable ctes_recursive Undocumented
Instance Variable dml_compile_state Optional :class:`.CompileState` assigned at the same point that .isinsert, .isupdate, or .isdelete is assigned.
Instance Variable escaped_bind_names Undocumented
Instance Variable for_executemany Undocumented
Instance Variable from_linter Undocumented
Instance Variable has_out_parameters if True, there are bindparam() objects that have the isoutparam flag set.
Instance Variable inline Undocumented
Instance Variable isdelete Undocumented
Instance Variable isinsert Undocumented
Instance Variable isplaintext Undocumented
Instance Variable isupdate class-level defaults which can be set at the instance level to define if this Compiled instance represents INSERT/UPDATE/DELETE
Instance Variable label_length Undocumented
Instance Variable level_name_by_cte Undocumented
Instance Variable linting Undocumented
Instance Variable next_numeric_pos Undocumented
Instance Variable positional Undocumented
Instance Variable positiontup for a compiled construct that uses a positional paramstyle, will be a sequence of strings, indicating the names of bound parameters in order.
Instance Variable stack major statements such as SELECT, INSERT, UPDATE, DELETE are tracked in this stack using an entry format.
Instance Variable string The string representation of the ``statement``
Instance Variable truncated_names Undocumented
Property current_executable Return the current 'executable' that is being compiled.
Property effective_returning The effective "returning" columns for INSERT, UPDATE or DELETE.
Property insert_single_values_expr When an INSERT is compiled with a single set of parameters inside a VALUES expression, the string is assigned here, where it can be used for insert batching schemes to rewrite the VALUES expression.
Property params Return the bind param dictionary embedded into this compiled object, for those values that are present.
Property prefetch Undocumented
Property returning backwards compatibility; returns the effective_returning collection.
Property sql_compiler Return a Compiled that is capable of processing SQL expressions.
Class Method _init_bind_translate Undocumented
Class Method _init_compiler_cls Undocumented
Method _add_to_result_map Undocumented
Method _anonymize Undocumented
Method _compose_select_body Undocumented
Method _create_result_map utility method used for unit tests only.
Method _deliver_insertmanyvalues_batches Undocumented
Method _dispatch_independent_ctes Undocumented
Method _display_froms_for_select Undocumented
Method _fallback_column_name Undocumented
Method _format_frame_clause Undocumented
Method _generate_delimited_and_list Undocumented
Method _generate_delimited_list Undocumented
Method _generate_generic_binary Undocumented
Method _generate_generic_unary_modifier Undocumented
Method _generate_generic_unary_operator Undocumented
Method _generate_prefixes Undocumented
Method _get_operator_dispatch Undocumented
Method _get_set_input_sizes_lookup Undocumented
Method _init_cte_state Initialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise.
Method _insert_stmt_should_use_insertmanyvalues Undocumented
Method _label_returning_column Render a column with necessary labels inside of a RETURNING clause.
Method _label_select_column produce labeled columns present in a select().
Method _literal_execute_expanding_parameter Undocumented
Method _literal_execute_expanding_parameter_literal_binds Undocumented
Method _nested_result special API to support the use case of 'nested result sets'
Method _process_numeric Undocumented
Method _process_parameters_for_postcompile handle special post compile parameters.
Method _process_positional Undocumented
Method _render_cte_clause include_following_stack Also render the nesting CTEs on the next stack. Useful for SQL structures like UNION or INSERT that can wrap SELECT statements containing nesting CTEs.
Method _render_values Undocumented
Method _row_limit_clause Undocumented
Method _setup_crud_hints Undocumented
Method _setup_select_hints Undocumented
Method _setup_select_stack Undocumented
Method _truncate_bindparam Undocumented
Method _truncated_identifier Undocumented
Class Variable _bind_translate_chars Undocumented
Class Variable _bind_translate_re Undocumented
Class Variable _default_stack_entry Undocumented
Class Variable _get_bind_name_for_col Undocumented
Class Variable _insert_crud_params Undocumented
Class Variable _positional_pattern Undocumented
Class Variable _post_compile_pattern Undocumented
Class Variable _pyformat_pattern Undocumented
Class Variable _values_bindparam Undocumented
Class Variable _visited_bindparam Undocumented
Instance Variable _ad_hoc_textual tell the result that we encountered text() or '*' constructs in the middle of the result columns, but we also have compiled columns, so if the number of columns in cursor.description does not match how many expressions we have, that means we can't rely on positional at all and should match on name.
Instance Variable _cache_key_bind_match a mapping that will relate the BindParameter object we compile to those that are part of the extracted collection of parameters in the cache key, if we were given a cache key.
Instance Variable _insertmanyvalues Undocumented
Instance Variable _loose_column_name_matching tell the result object that the SQL statement is textual, wants to match up to Column objects, and may be using the ._tq_label in the SELECT rather than the base name.
Instance Variable _numeric_binds True if paramstyle is "numeric". This paramstyle is trickier than all the others.
Instance Variable _numeric_binds_identifier_char Character that's used to as the identifier of a numerical bind param. For example if this char is set to ``$``, numerical binds will be rendered in the form ``$1, $2, $3``.
Instance Variable _ordered_columns if False, means we can't be sure the list of entries in _result_columns is actually the rendered order. Usually True unless using an unordered TextualSelect.
Instance Variable _post_compile_expanded_state When render_postcompile is used, the ``ExpandedState`` used to create the "expanded" SQL is assigned here, and then used by the ``.params`` accessor and ``.construct_params()`` methods for their return values.
Instance Variable _pre_expanded_positiontup Undocumented
Instance Variable _pre_expanded_string Stores the original string SQL before 'post_compile' is applied, for cases where 'post_compile' were used.
Instance Variable _render_postcompile whether to render out POSTCOMPILE params during the compile phase.
Instance Variable _result_columns relates label names in the final SQL to a tuple of local column/label name, ColumnElement object (if any) and TypeEngine. CursorResult uses this for type processing and column targeting
Instance Variable _textual_ordered_columns tell the result object that the column names as rendered are important, but they are also "ordered" vs. what is in the compiled object here.
Instance Variable _truncated_counters Undocumented
Property _bind_processors Undocumented
Property _global_attributes Undocumented
Property _inserted_primary_key_from_lastrowid_getter Undocumented
Property _inserted_primary_key_from_returning_getter Undocumented
Property _like_percent_literal Undocumented
Property _within_exec_param_key_getter Undocumented

Inherited from Compiled:

Method __init_subclass__ Undocumented
Method __str__ Return the string text of the generated SQL or DDL.
Method process Undocumented
Method visit_unsupported_compilation Undocumented
Class Variable is_ddl Undocumented
Instance Variable can_execute Undocumented
Instance Variable dialect Undocumented
Instance Variable execution_options Undocumented
Instance Variable preparer Undocumented
Instance Variable schema_translate_map Execution options propagated from the statement. In some cases, sub-elements of the statement can modify these.
Instance Variable state description of the compiler's state
Instance Variable statement The statement to compile.
Method _execute_on_connection Undocumented
Class Variable _cached_metadata Undocumented
Instance Variable _annotations Undocumented
Instance Variable _gen_time Generation time of this :class:`.Compiled`, used for reporting cache stats.
def __init__(self, dialect: Dialect, statement: Optional[ClauseElement], cache_key: Optional[CacheKey] = None, column_keys: Optional[Sequence[str]] = None, for_executemany: bool = False, linting: Linting = NO_LINTING, **kwargs: Any): (source)

Construct a new :class:`.SQLCompiler` object. :param dialect: :class:`.Dialect` to be used :param statement: :class:`_expression.ClauseElement` to be compiled :param column_keys: a list of column names to be compiled into an INSERT or UPDATE statement. :param for_executemany: whether INSERT / UPDATE statements should expect that they are to be invoked in an "executemany" style, which may impact how the statement will be expected to return the values of defaults and autoincrement / sequences and similar. Depending on the backend and driver in use, support for retrieving these values may be disabled which means SQL expressions may be rendered inline, RETURNING may not be rendered, etc. :param kwargs: additional keyword arguments to be consumed by the superclass.

def bindparam_string(self, name: str, post_compile: bool = False, expanding: bool = False, escaped_from: Optional[str] = None, bindparam_type: Optional[TypeEngine[Any]] = None, accumulate_bind_names: Optional[Set[str]] = None, visited_bindparam: Optional[List[str]] = None, **kw: Any) -> str: (source)
def construct_expanded_state(self, params: Optional[_CoreSingleExecuteParams] = None, escape_names: bool = True) -> ExpandedState: (source)

Return a new :class:`.ExpandedState` for a given parameter set. For queries that use "expanding" or other late-rendered parameters, this method will provide for both the finalized SQL string as well as the parameters that would be used for a particular parameter set. .. versionadded:: 2.0.0rc1

def construct_params(self, params: Optional[_CoreSingleExecuteParams] = None, extracted_parameters: Optional[Sequence[BindParameter[Any]]] = None, escape_names: bool = True, _group_number: Optional[int] = None, _check: bool = True, _no_postcompile: bool = False) -> _MutableCoreSingleExecuteParams: (source)

return a dictionary of bind parameter keys and values

def default_from(self): (source)

Called when a SELECT statement has no froms, and no FROM clause is to be appended. Gives Oracle a chance to tack on a ``FROM DUAL`` to the string output.

def delete_extra_from_clause(self, update_stmt, from_table, extra_froms, from_hints, **kw): (source)

Provide a hook to override the generation of an DELETE..FROM clause. This can be used to implement DELETE..USING for example. MySQL and MSSQL override this.

def delete_table_clause(self, delete_stmt, from_table, extra_froms): (source)
def escape_literal_column(self, text): (source)

Undocumented

def fetch_clause(self, select, fetch_clause=None, require_offset=False, use_literal_execute_for_simple_int=False, **kw): (source)
def format_from_hint_text(self, sqltext, table, hint, iscrud): (source)
def function_argspec(self, func, **kwargs): (source)
def get_crud_hint_text(self, table, text): (source)
def get_render_as_alias_suffix(self, alias_name_text): (source)
def get_select_hint_text(self, byfroms): (source)
def get_select_precolumns(self, select, **kw): (source)

Called when building a ``SELECT`` statement, position is just before column list.

def get_statement_hint_text(self, hint_texts): (source)

Undocumented

def group_by_clause(self, select, **kw): (source)

allow dialects to customize how GROUP BY is rendered.

def is_subquery(self): (source)

Undocumented

def order_by_clause(self, select, **kw): (source)

allow dialects to customize how ORDER BY is rendered.

def post_process_text(self, text): (source)

Undocumented

def render_bind_cast(self, type_, dbapi_type, sqltext): (source)
def render_literal_bindparam(self, bindparam, render_literal_value=NO_ARG, bind_expression_template=None, **kw): (source)

Undocumented

def render_literal_value(self, value, type_): (source)

Render the value of a bind parameter as a quoted literal. This is used for statement sections that do not accept bind parameters on the target driver/database. This should be implemented by subclasses using the quoting services of the DBAPI.

def update_from_clause(self, update_stmt, from_table, extra_froms, from_hints, **kw): (source)
def update_limit_clause(self, update_stmt): (source)

Provide a hook for MySQL to add LIMIT to the UPDATE

def update_tables_clause(self, update_stmt, from_table, extra_froms, **kw): (source)

Provide a hook to override the initial table clause in an UPDATE statement. MySQL overrides this.

def visit_alias(self, alias, asfrom=False, ashint=False, iscrud=False, fromhints=None, subquery=False, lateral=False, enclosing_alias=None, from_linter=None, **kwargs): (source)
def visit_between_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_binary(self, binary, override_operator=None, eager_grouping=False, from_linter=None, lateral_from_linter=None, **kw): (source)
def visit_bindparam(self, bindparam, within_columns_clause=False, literal_binds=False, skip_bind_expression=False, literal_execute=False, render_postcompile=False, **kwargs): (source)

Undocumented

def visit_case(self, clause, **kwargs): (source)

Undocumented

def visit_clauselist(self, clauselist, **kw): (source)

Undocumented

def visit_collation(self, element, **kw): (source)

Undocumented

def visit_column(self, column: ColumnClause[Any], add_to_result_map: Optional[_ResultMapAppender] = None, include_table: bool = True, result_map_targets: Tuple[Any, ...] = (), ambiguous_table_name_map: Optional[_AmbiguousTableNameMap] = None, **kwargs: Any) -> str: (source)
def visit_compound_select(self, cs, asfrom=False, compound_index=None, **kwargs): (source)

Undocumented

def visit_contains_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_cte(self, cte: CTE, asfrom: bool = False, ashint: bool = False, fromhints: Optional[_FromHintsType] = None, visiting_cte: Optional[CTE] = None, from_linter: Optional[FromLinter] = None, cte_opts: selectable._CTEOpts = selectable._CTEOpts(False), **kwargs: Any) -> Optional[str]: (source)

Undocumented

def visit_custom_op_binary(self, element, operator, **kw): (source)

Undocumented

def visit_custom_op_unary_modifier(self, element, operator, **kw): (source)

Undocumented

def visit_custom_op_unary_operator(self, element, operator, **kw): (source)

Undocumented

def visit_delete(self, delete_stmt, **kw): (source)

Undocumented

def visit_empty_set_op_expr(self, type_, expand_op, **kw): (source)
def visit_endswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_expression_clauselist(self, clauselist, **kw): (source)

Undocumented

def visit_extract(self, extract, **kwargs): (source)
def visit_floordiv_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_fromclause(self, fromclause, **kwargs): (source)

Undocumented

def visit_funcfilter(self, funcfilter, **kwargs): (source)

Undocumented

def visit_function(self, func: Function[Any], add_to_result_map: Optional[_ResultMapAppender] = None, **kwargs: Any) -> str: (source)
def visit_function_as_comparison_op_binary(self, element, operator, **kw): (source)

Undocumented

def visit_grouping(self, grouping, asfrom=False, **kwargs): (source)

Undocumented

def visit_icontains_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_iendswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_ilike_case_insensitive_operand(self, element, **kw): (source)
def visit_ilike_op_binary(self, binary, operator, **kw): (source)
def visit_index(self, index, **kwargs): (source)

Undocumented

def visit_insert(self, insert_stmt, visited_bindparam=None, **kw): (source)

Undocumented

def visit_is_false_unary_operator(self, element, operator, **kw): (source)

Undocumented

def visit_is_true_unary_operator(self, element, operator, **kw): (source)

Undocumented

def visit_istartswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_join(self, join, asfrom=False, from_linter=None, **kwargs): (source)
def visit_label(self, label, add_to_result_map=None, within_label_clause=False, within_columns_clause=False, render_label_as_label=None, result_map_targets=(), **kw): (source)

Undocumented

def visit_label_reference(self, element, within_columns_clause=False, **kwargs): (source)

Undocumented

def visit_lambda_element(self, element, **kw): (source)

Undocumented

def visit_lateral(self, lateral_, **kw): (source)

Undocumented

def visit_like_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_next_value_func(self, next_value, **kw): (source)

Undocumented

def visit_not_between_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_contains_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_endswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_icontains_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_iendswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_ilike_op_binary(self, binary, operator, **kw): (source)
def visit_not_in_op_binary(self, binary, operator, **kw): (source)
def visit_not_istartswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_like_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_match_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_not_startswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_null(self, expr, **kw): (source)

Undocumented

def visit_over(self, over, **kwargs): (source)

Undocumented

def visit_release_savepoint(self, savepoint_stmt, **kw): (source)

Undocumented

def visit_rollback_to_savepoint(self, savepoint_stmt, **kw): (source)
def visit_savepoint(self, savepoint_stmt, **kw): (source)
def visit_scalar_function_column(self, element, **kw): (source)

Undocumented

def visit_scalar_values(self, element, **kw): (source)

Undocumented

def visit_select(self, select_stmt, asfrom=False, insert_into=False, fromhints=None, compound_index=None, select_wraps_for=None, lateral=False, from_linter=None, **kwargs): (source)

Undocumented

def visit_select_statement_grouping(self, grouping, **kwargs): (source)

Undocumented

def visit_startswith_op_binary(self, binary, operator, **kw): (source)

Undocumented

def visit_subquery(self, subquery, **kw): (source)

Undocumented

def visit_table(self, table, asfrom=False, iscrud=False, ashint=False, fromhints=None, use_schema=True, from_linter=None, ambiguous_table_name_map=None, **kwargs): (source)
def visit_table_valued_alias(self, element, **kw): (source)

Undocumented

def visit_table_valued_column(self, element, **kw): (source)
def visit_tablesample(self, tablesample, asfrom=False, **kw): (source)

Undocumented

def visit_textclause(self, textclause, add_to_result_map=None, **kw): (source)

Undocumented

def visit_textual_label_reference(self, element, within_columns_clause=False, **kwargs): (source)

Undocumented

def visit_textual_select(self, taf, compound_index=None, asfrom=False, **kw): (source)

Undocumented

def visit_truediv_binary(self, binary, operator, **kw): (source)
def visit_tuple(self, clauselist, **kw): (source)

Undocumented

def visit_type_coerce(self, type_coerce, **kw): (source)

Undocumented

def visit_typeclause(self, typeclause, **kw): (source)
def visit_unary(self, unary, add_to_result_map=None, result_map_targets=(), **kw): (source)

Undocumented

def visit_update(self, update_stmt, **kw): (source)

Undocumented

def visit_values(self, element, asfrom=False, from_linter=None, **kw): (source)

Undocumented

def visit_withingroup(self, withingroup, **kwargs): (source)

Undocumented

ansi_bind_rules: bool = (source)

SQL 92 doesn't allow bind parameters to be used in the columns clause of a SELECT, nor does it allow ambiguous expressions like "? = ?". A compiler subclass can set this flag to False if the target driver/DB enforces this

bindname_escape_characters: ClassVar[Mapping[str, str]] = (source)

A mapping (e.g. dict or similar) containing a lookup of characters keyed to replacement characters which will be applied to all 'bind names' used in SQL statements as a form of 'escaping'; the given characters are replaced entirely with the 'replacement' character when rendered in the SQL statement, and a similar translation is performed on the incoming names used in parameter dictionaries passed to methods like :meth:`_engine.Connection.execute`. This allows bound parameter names used in :func:`_sql.bindparam` and other constructs to have any arbitrary characters present without any concern for characters that aren't allowed at all on the target database. Third party dialects can establish their own dictionary here to replace the default mapping, which will ensure that the particular characters in the mapping will never appear in a bound parameter name. The dictionary is evaluated at **class creation time**, so cannot be modified at runtime; it must be present on the class when the class is first declared. Note that for dialects that have additional bound parameter rules such as additional restrictions on leading characters, the :meth:`_sql.SQLCompiler.bindparam_string` method may need to be augmented. See the cx_Oracle compiler for an example of this. .. versionadded:: 2.0.0rc1

list of "implicit" returning columns for a toplevel INSERT or UPDATE statement, used to receive newly generated values of columns. .. versionadded:: 2.0 ``implicit_returning`` replaces the previous ``returning`` collection, which was not a generalized RETURNING collection and instead was in fact specific to the "implicit returning" feature.

insert_prefetch: Sequence[Column[Any]] = (source)

list of columns for which default values should be evaluated before an INSERT takes place

literal_execute_params: FrozenSet[BindParameter[Any]] = (source)

bindparameter objects that are rendered as literal values at statement execution time.

post_compile_params: FrozenSet[BindParameter[Any]] = (source)

bindparameter objects that are rendered as bound parameter placeholders at statement execution time.

list of columns that can be post-fetched after INSERT or UPDATE to receive server-updated values

postfetch_lastrowid: bool = (source)

if True, and this in insert, use cursor.lastrowid to populate result.inserted_primary_key.

render_table_with_column_in_update_from: bool = (source)

set to True classwide to indicate the SET clause in a multi-table UPDATE statement should qualify columns with the table name (i.e. MySQL only)

returning_precedes_values: bool = (source)

set to True classwide to generate RETURNING clauses before the VALUES or WHERE clause (i.e. MSSQL)

translate_select_structure: Any = (source)

if not ``None``, should be a callable which accepts ``(select_stmt, **kw)`` and returns a select object. this is used for structural changes mostly to accommodate for LIMIT/OFFSET schemes

update_prefetch: Sequence[Column[Any]] = (source)

list of columns for which onupdate default values should be evaluated before an UPDATE takes place

anon_map = (source)

Undocumented

bind_names = (source)

a dictionary of BindParameter instances to "compiled" names that are actually present in the generated SQL

a dictionary of bind parameter keys to BindParameter instances.

bindtemplate = (source)

template to render bound parameters based on paramstyle.

cache_key = (source)

The :class:`.CacheKey` that was generated ahead of creating this :class:`.Compiled` object. This is used for routines that need access to the original :class:`.CacheKey` instance generated when the :class:`.Compiled` instance was first cached, typically in order to reconcile the original list of :class:`.BindParameter` objects with a per-statement list that's generated on each call.

column_keys = (source)

Undocumented

compilation_bindtemplate = (source)

template used by compiler to render parameters before positional paramstyle application

compile_state = (source)

Optional :class:`.CompileState` object that maintains additional state used by the compiler. Major executable objects such as :class:`_expression.Insert`, :class:`_expression.Update`, :class:`_expression.Delete`, :class:`_expression.Select` will generate this state when compiled in order to calculate additional information about the object. For the top level object that is to be executed, the state can be stored here where it can also have applicability towards result set processing. .. versionadded:: 1.4

Undocumented

ctes_by_level_name: dict = (source)

Undocumented

ctes_recursive: bool = (source)

Undocumented

dml_compile_state = (source)

Optional :class:`.CompileState` assigned at the same point that .isinsert, .isupdate, or .isdelete is assigned. This will normally be the same object as .compile_state, with the exception of cases like the :class:`.ORMFromStatementCompileState` object. .. versionadded:: 1.4.40

escaped_bind_names = (source)

Undocumented

for_executemany = (source)

Undocumented

from_linter = (source)

Undocumented

has_out_parameters: bool = (source)

if True, there are bindparam() objects that have the isoutparam flag set.

Undocumented

isdelete: bool = (source)

Undocumented

isinsert: bool = (source)

Undocumented

isplaintext: bool = (source)

Undocumented

isupdate: bool = (source)

class-level defaults which can be set at the instance level to define if this Compiled instance represents INSERT/UPDATE/DELETE

label_length = (source)

Undocumented

level_name_by_cte: dict = (source)

Undocumented

Undocumented

next_numeric_pos = (source)

Undocumented

positional = (source)

Undocumented

positiontup = (source)

for a compiled construct that uses a positional paramstyle, will be a sequence of strings, indicating the names of bound parameters in order. This is used in order to render bound parameters in their correct order, and is combined with the :attr:`_sql.Compiled.params` dictionary to render parameters. This sequence always contains the unescaped name of the parameters. .. seealso:: :ref:`faq_sql_expression_string` - includes a usage example for debugging use cases.

major statements such as SELECT, INSERT, UPDATE, DELETE are tracked in this stack using an entry format.

The string representation of the ``statement``

truncated_names: Dict[Tuple[str, str], str] = (source)

Undocumented

@property
current_executable = (source)

Return the current 'executable' that is being compiled. This is currently the :class:`_sql.Select`, :class:`_sql.Insert`, :class:`_sql.Update`, :class:`_sql.Delete`, :class:`_sql.CompoundSelect` object that is being compiled. Specifically it's assigned to the ``self.stack`` list of elements. When a statement like the above is being compiled, it normally is also assigned to the ``.statement`` attribute of the :class:`_sql.Compiler` object. However, all SQL constructs are ultimately nestable, and this attribute should never be consulted by a ``visit_`` method, as it is not guaranteed to be assigned nor guaranteed to correspond to the current statement being compiled. .. versionadded:: 1.3.21 For compatibility with previous versions, use the following recipe:: statement = getattr(self, "current_executable", False) if statement is False: statement = self.stack[-1]["selectable"] For versions 1.4 and above, ensure only .current_executable is used; the format of "self.stack" may change.

@util.ro_memoized_property
effective_returning: Optional[Sequence[ColumnElement[Any]]] = (source)

The effective "returning" columns for INSERT, UPDATE or DELETE. This is either the so-called "implicit returning" columns which are calculated by the compiler on the fly, or those present based on what's present in ``self.statement._returning`` (expanded into individual columns using the ``._all_selected_columns`` attribute) i.e. those set explicitly using the :meth:`.UpdateBase.returning` method. .. versionadded:: 2.0

@property
insert_single_values_expr: Optional[str] = (source)

When an INSERT is compiled with a single set of parameters inside a VALUES expression, the string is assigned here, where it can be used for insert batching schemes to rewrite the VALUES expression. .. versionadded:: 1.3.8 .. versionchanged:: 2.0 This collection is no longer used by SQLAlchemy's built-in dialects, in favor of the currently internal ``_insertmanyvalues`` collection that is used only by :class:`.SQLCompiler`.

Return the bind param dictionary embedded into this compiled object, for those values that are present. .. seealso:: :ref:`faq_sql_expression_string` - includes a usage example for debugging use cases.

Undocumented

backwards compatibility; returns the effective_returning collection.

@property
sql_compiler = (source)

Return a Compiled that is capable of processing SQL expressions. If this compiler is one, it would likely just return 'self'.

@classmethod
def _init_bind_translate(cls): (source)

Undocumented

@classmethod
def _init_compiler_cls(cls): (source)
def _add_to_result_map(self, keyname: str, name: str, objects: Tuple[Any, ...], type_: TypeEngine[Any]): (source)

Undocumented

def _anonymize(self, name: str) -> str: (source)

Undocumented

def _compose_select_body(self, text, select, compile_state, inner_columns, froms, byfrom, toplevel, kwargs): (source)

Undocumented

@util.preload_module('sqlalchemy.engine.cursor')
def _create_result_map(self): (source)

utility method used for unit tests only.

def _deliver_insertmanyvalues_batches(self, statement, parameters, generic_setinputsizes, batch_size): (source)

Undocumented

def _dispatch_independent_ctes(self, stmt, kw): (source)

Undocumented

def _display_froms_for_select(self, select_stmt, asfrom, lateral=False, **kw): (source)

Undocumented

def _fallback_column_name(self, column): (source)

Undocumented

def _format_frame_clause(self, range_, **kw): (source)

Undocumented

def _generate_delimited_and_list(self, clauses, **kw): (source)

Undocumented

def _generate_delimited_list(self, elements, separator, **kw): (source)

Undocumented

def _generate_generic_binary(self, binary, opstring, eager_grouping=False, **kw): (source)

Undocumented

def _generate_generic_unary_modifier(self, unary, opstring, **kw): (source)

Undocumented

def _generate_generic_unary_operator(self, unary, opstring, **kw): (source)

Undocumented

def _generate_prefixes(self, stmt, prefixes, **kw): (source)

Undocumented

def _get_operator_dispatch(self, operator_, qualifier1, qualifier2): (source)

Undocumented

@util.memoized_instancemethod
def _get_set_input_sizes_lookup(self): (source)

Undocumented

Initialize collections related to CTEs only if a CTE is located, to save on the overhead of these collections otherwise.

def _insert_stmt_should_use_insertmanyvalues(self, statement): (source)

Undocumented

def _label_returning_column(self, stmt, column, populate_result_map, column_clause_args=None, **kw): (source)

Render a column with necessary labels inside of a RETURNING clause. This method is provided for individual dialects in place of calling the _label_select_column method directly, so that the two use cases of RETURNING vs. SELECT can be disambiguated going forward. .. versionadded:: 1.4.21

def _label_select_column(self, select, column, populate_result_map, asfrom, column_clause_args, name=None, proxy_name=None, fallback_label_name=None, within_columns_clause=True, column_is_repeated=False, need_column_expressions=False, include_table=True): (source)

produce labeled columns present in a select().

def _literal_execute_expanding_parameter(self, name, parameter, values): (source)

Undocumented

def _literal_execute_expanding_parameter_literal_binds(self, parameter, values, bind_expression_template=None): (source)

Undocumented

@contextlib.contextmanager
def _nested_result(self): (source)

special API to support the use case of 'nested result sets'

def _process_numeric(self): (source)

Undocumented

def _process_parameters_for_postcompile(self, parameters: _MutableCoreSingleExecuteParams, _populate_self: bool = False) -> ExpandedState: (source)

handle special post compile parameters. These include: * "expanding" parameters -typically IN tuples that are rendered on a per-parameter basis for an otherwise fixed SQL statement string. * literal_binds compiled with the literal_execute flag. Used for things like SQL Server "TOP N" where the driver does not accommodate N as a bound parameter.

def _process_positional(self): (source)

Undocumented

def _render_cte_clause(self, nesting_level=None, include_following_stack=False): (source)

include_following_stack Also render the nesting CTEs on the next stack. Useful for SQL structures like UNION or INSERT that can wrap SELECT statements containing nesting CTEs.

def _render_values(self, element, **kw): (source)

Undocumented

def _setup_crud_hints(self, stmt, table_text): (source)

Undocumented

def _setup_select_hints(self, select: Select[Any]) -> Tuple[str, _FromHintsType]: (source)

Undocumented

def _setup_select_stack(self, select, compile_state, entry, asfrom, lateral, compound_index): (source)

Undocumented

def _truncate_bindparam(self, bindparam): (source)

Undocumented

def _truncated_identifier(self, ident_class: str, name: _truncated_label) -> str: (source)

Undocumented

_bind_translate_chars: ClassVar[Mapping[str, str]] = (source)

Undocumented

_bind_translate_re: ClassVar[Pattern[str]] = (source)

Undocumented

_default_stack_entry = (source)

Undocumented

_get_bind_name_for_col: _BindNameForColProtocol = (source)

Undocumented

Undocumented

_positional_pattern = (source)

Undocumented

_post_compile_pattern = (source)

Undocumented

_pyformat_pattern = (source)

Undocumented

_values_bindparam: Optional[List[str]] = (source)

Undocumented

_visited_bindparam: Optional[List[str]] = (source)

Undocumented

_ad_hoc_textual: bool = (source)

tell the result that we encountered text() or '*' constructs in the middle of the result columns, but we also have compiled columns, so if the number of columns in cursor.description does not match how many expressions we have, that means we can't rely on positional at all and should match on name.

_cache_key_bind_match = (source)

a mapping that will relate the BindParameter object we compile to those that are part of the extracted collection of parameters in the cache key, if we were given a cache key.

_insertmanyvalues = (source)

Undocumented

_loose_column_name_matching = (source)

tell the result object that the SQL statement is textual, wants to match up to Column objects, and may be using the ._tq_label in the SELECT rather than the base name.

_numeric_binds = (source)

True if paramstyle is "numeric". This paramstyle is trickier than all the others.

_numeric_binds_identifier_char = (source)

Character that's used to as the identifier of a numerical bind param. For example if this char is set to ``$``, numerical binds will be rendered in the form ``$1, $2, $3``.

_ordered_columns: bool = (source)

if False, means we can't be sure the list of entries in _result_columns is actually the rendered order. Usually True unless using an unordered TextualSelect.

_post_compile_expanded_state = (source)

When render_postcompile is used, the ``ExpandedState`` used to create the "expanded" SQL is assigned here, and then used by the ``.params`` accessor and ``.construct_params()`` methods for their return values. .. versionadded:: 2.0.0rc1

_pre_expanded_positiontup = (source)

Undocumented

_pre_expanded_string = (source)

Stores the original string SQL before 'post_compile' is applied, for cases where 'post_compile' were used.

_render_postcompile: bool = (source)

whether to render out POSTCOMPILE params during the compile phase. This attribute is used only for end-user invocation of stmt.compile(); it's never used for actual statement execution, where instead the dialect internals access and render the internal postcompile structure directly.

_result_columns = (source)

relates label names in the final SQL to a tuple of local column/label name, ColumnElement object (if any) and TypeEngine. CursorResult uses this for type processing and column targeting

_textual_ordered_columns = (source)

tell the result object that the column names as rendered are important, but they are also "ordered" vs. what is in the compiled object here. As of 1.4.42 this condition is only present when the statement is a TextualSelect, e.g. text("....").columns(...), where it is required that the columns are considered positionally and not by name.

_truncated_counters: Dict[str, int] = (source)

Undocumented

@util.memoized_property
_bind_processors: MutableMapping[str, Union[_BindProcessorType[Any], Sequence[_BindProcessorType[Any]]]] = (source)

Undocumented

@util.memoized_property
_global_attributes: Dict[Any, Any] = (source)

Undocumented

@util.memoized_property
@util.preload_module('sqlalchemy.engine.result')
_inserted_primary_key_from_lastrowid_getter = (source)

Undocumented

@util.memoized_property
@util.preload_module('sqlalchemy.engine.result')
_inserted_primary_key_from_returning_getter = (source)

Undocumented

@util.memoized_property
_like_percent_literal = (source)

Undocumented

@util.memoized_property
_within_exec_param_key_getter: Callable[[Any], str] = (source)

Undocumented