MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/sql/compiler.py:859–914  ·  view source on GitHub ↗

Construct a new :class:`.Compiled` object. :param dialect: :class:`.Dialect` to compile against. :param statement: :class:`_expression.ClauseElement` to be compiled. :param schema_translate_map: dictionary of schema names to be translated when forming the resultan

(
        self,
        dialect: Dialect,
        statement: Optional[ClauseElement],
        schema_translate_map: Optional[SchemaTranslateMapType] = None,
        render_schema_translate: bool = False,
        compile_kwargs: Mapping[str, Any] = util.immutabledict(),
    )

Source from the content-addressed store, hash-verified

857 cache stats."""
858
859 def __init__(
860 self,
861 dialect: Dialect,
862 statement: Optional[ClauseElement],
863 schema_translate_map: Optional[SchemaTranslateMapType] = None,
864 render_schema_translate: bool = False,
865 compile_kwargs: Mapping[str, Any] = util.immutabledict(),
866 ):
867 """Construct a new :class:`.Compiled` object.
868
869 :param dialect: :class:`.Dialect` to compile against.
870
871 :param statement: :class:`_expression.ClauseElement` to be compiled.
872
873 :param schema_translate_map: dictionary of schema names to be
874 translated when forming the resultant SQL
875
876 .. seealso::
877
878 :ref:`schema_translating`
879
880 :param compile_kwargs: additional kwargs that will be
881 passed to the initial call to :meth:`.Compiled.process`.
882
883
884 """
885 self.dialect = dialect
886 self.preparer = self.dialect.identifier_preparer
887 if schema_translate_map:
888 self.schema_translate_map = schema_translate_map
889 self.preparer = self.preparer._with_schema_translate(
890 schema_translate_map
891 )
892
893 if statement is not None:
894 self.state = CompilerState.COMPILING
895 self.statement = statement
896 self.can_execute = statement.supports_execution
897 self._annotations = statement._annotations
898 if self.can_execute:
899 if TYPE_CHECKING:
900 assert isinstance(statement, Executable)
901 self.execution_options = statement._execution_options
902 self.string = self.process(self.statement, **compile_kwargs)
903
904 if render_schema_translate:
905 assert schema_translate_map is not None
906 self.string = self.preparer._render_schema_translates(
907 self.string, schema_translate_map
908 )
909
910 self.state = CompilerState.STRING_APPLIED
911 else:
912 self.state = CompilerState.NO_STATEMENT
913
914 self._gen_time = perf_counter()
915
916 def __init_subclass__(cls) -> None:

Callers 1

__init__Method · 0.45

Calls 3

processMethod · 0.95

Tested by

no test coverage detected