MCPcopy Index your code
hub / github.com/fastapi/sqlmodel / execute

Method execute

sqlmodel/orm/session.py:108–143  ·  view source on GitHub ↗

🚨 You probably want to use `session.exec()` instead of `session.execute()`. This is the original SQLAlchemy `session.execute()` method that returns objects of type `Row`, and that you have to call `scalars()` to get the model objects. For example: ```Pytho

(
        self,
        statement: _Executable,
        params: _CoreAnyExecuteParams | None = None,
        *,
        execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT,
        bind_arguments: dict[str, Any] | None = None,
        _parent_execute_state: Any | None = None,
        _add_event: Any | None = None,
    )

Source from the content-addressed store, hash-verified

106 category=None,
107 )
108 def execute(
109 self,
110 statement: _Executable,
111 params: _CoreAnyExecuteParams | None = None,
112 *,
113 execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT,
114 bind_arguments: dict[str, Any] | None = None,
115 _parent_execute_state: Any | None = None,
116 _add_event: Any | None = None,
117 ) -> Result[Any]:
118 """
119 🚨 You probably want to use `session.exec()` instead of `session.execute()`.
120
121 This is the original SQLAlchemy `session.execute()` method that returns objects
122 of type `Row`, and that you have to call `scalars()` to get the model objects.
123
124 For example:
125
126 ```Python
127 heroes = session.execute(select(Hero)).scalars().all()
128 ```
129
130 instead you could use `exec()`:
131
132 ```Python
133 heroes = session.exec(select(Hero)).all()
134 ```
135 """
136 return super().execute(
137 statement,
138 params=params,
139 execution_options=execution_options,
140 bind_arguments=bind_arguments,
141 _parent_execute_state=_parent_execute_state,
142 _add_event=_add_event,
143 )
144
145 @deprecated(
146 """

Callers 4

execMethod · 0.45
create_db_and_tablesFunction · 0.45
create_db_and_tablesFunction · 0.45
create_db_and_tablesFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected