|
11 | 11 |
|
12 | 12 | .. _tutorial_core_insert: |
13 | 13 |
|
14 | | -Inserting Rows with Core |
15 | | -------------------------- |
| 14 | +Inserting Rows with ``Insert()`` Constructs |
| 15 | +------------------------------------------- |
16 | 16 |
|
17 | | -When using Core, a SQL INSERT statement is generated using the |
18 | | -:func:`_sql.insert` function - this function generates a new instance of |
19 | | -:class:`_sql.Insert` which represents an INSERT statement in SQL, that adds |
20 | | -new data into a table. |
| 17 | +When using Core as well as within some ORM use cases, a SQL INSERT statement is |
| 18 | +generated directly using the :func:`_sql.insert` function - this function |
| 19 | +generates a new instance of :class:`_sql.Insert` which represents an INSERT |
| 20 | +statement in SQL, that adds new data into a table. |
21 | 21 |
|
22 | 22 | .. container:: orm-header |
23 | 23 |
|
24 | | - **ORM Readers** - The way that rows are INSERTed into the database from an ORM |
25 | | - perspective makes use of object-centric APIs on the :class:`_orm.Session` object known as the |
26 | | - :term:`unit of work` process, |
27 | | - and is fairly different from the Core-only approach described here. |
28 | | - The more ORM-focused sections later starting at :ref:`tutorial_inserting_orm` |
29 | | - subsequent to the Expression Language sections introduce this. |
| 24 | + **ORM Readers** - |
| 25 | + |
| 26 | + The ORM's means of generating INSERT statements is described in |
| 27 | + one of two ways; the most common is by using |
| 28 | + the :term:`unit of work` process which automates the generation of |
| 29 | + INSERT statements from object state, and is introduced |
| 30 | + at :ref:`tutorial_inserting_orm`. The other is by using |
| 31 | + the :class:`_sql.Insert` construct directly |
| 32 | + in a manner very similar to that described in this section; this use |
| 33 | + is introduced at :ref:`tutorial_orm_bulk`. |
| 34 | + |
30 | 35 |
|
31 | 36 | The insert() SQL Expression Construct |
32 | 37 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
@@ -249,21 +254,13 @@ as in the example below that builds upon the example stated in |
249 | 254 |
|
250 | 255 | The RETURNING feature is also supported by UPDATE and DELETE statements, |
251 | 256 | which will be introduced later in this tutorial. |
252 | | - The RETURNING feature is generally [1]_ only |
253 | | - supported for statement executions that use a single set of bound |
254 | | - parameters; that is, it won't work with the "executemany" form introduced |
255 | | - at :ref:`tutorial_multiple_parameters`. Additionally, some dialects |
256 | | - such as the Oracle dialect only allow RETURNING to return a single row |
257 | | - overall, meaning it won't work with "INSERT..FROM SELECT" nor will it |
258 | | - work with multiple row :class:`_sql.Update` or :class:`_sql.Delete` |
259 | | - forms. |
260 | | - |
261 | | - .. [1] There is internal support for the |
262 | | - :mod:`_postgresql.psycopg2` dialect to INSERT many rows at once |
263 | | - and also support RETURNING, which is leveraged by the SQLAlchemy |
264 | | - ORM. However this feature has not been generalized to all dialects |
265 | | - and is not yet part of SQLAlchemy's regular API. |
266 | 257 |
|
| 258 | + For INSERT statements, the RETURNING feature may be used |
| 259 | + both for single-row statements as well as for statements that INSERT |
| 260 | + multiple rows at once. Support for multiple-row INSERT with RETURNING |
| 261 | + is dialect specific, however is supported for all the dialects |
| 262 | + that are included in SQLAlchemy which support RETURNING. See the section |
| 263 | + :ref:`engine_insertmanyvalues` for background on this feature. |
267 | 264 |
|
268 | 265 |
|
269 | 266 | .. seealso:: |
|
0 commit comments