summaryrefslogtreecommitdiff
path: root/doc/build/tutorial
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-07-18 15:08:37 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-09-24 11:15:32 -0400
commit2bcc97da424eef7db9a5d02f81d02344925415ee (patch)
tree13d4f04bc7dd40a0207f86aa2fc3a3b49e065674 /doc/build/tutorial
parent332188e5680574368001ded52eb0a9d259ecdef5 (diff)
downloadsqlalchemy-2bcc97da424eef7db9a5d02f81d02344925415ee.tar.gz
implement batched INSERT..VALUES () () for executemany
the feature is enabled for all built in backends when RETURNING is used, except for Oracle that doesn't need it, and on psycopg2 and mssql+pyodbc it is used for all INSERT statements, not just those that use RETURNING. third party dialects would need to opt in to the new feature by setting use_insertmanyvalues to True. Also adds dialect-level guards against using returning with executemany where we dont have an implementation to suit it. execute single w/ returning still defers to the server without us checking. Fixes: #6047 Fixes: #7907 Change-Id: I3936d3c00003f02e322f2e43fb949d0e6e568304
Diffstat (limited to 'doc/build/tutorial')
-rw-r--r--doc/build/tutorial/orm_data_manipulation.rst7
-rw-r--r--doc/build/tutorial/orm_related_objects.rst7
2 files changed, 6 insertions, 8 deletions
diff --git a/doc/build/tutorial/orm_data_manipulation.rst b/doc/build/tutorial/orm_data_manipulation.rst
index b0b67f53c..f6237f4aa 100644
--- a/doc/build/tutorial/orm_data_manipulation.rst
+++ b/doc/build/tutorial/orm_data_manipulation.rst
@@ -122,10 +122,9 @@ method:
>>> session.flush()
{opensql}BEGIN (implicit)
- INSERT INTO user_account (name, fullname) VALUES (?, ?)
- [...] ('squidward', 'Squidward Tentacles')
- INSERT INTO user_account (name, fullname) VALUES (?, ?)
- [...] ('ehkrabs', 'Eugene H. Krabs')
+ INSERT INTO user_account (name, fullname) VALUES (?, ?), (?, ?) RETURNING id
+ [...] ('squidward', 'Squidward Tentacles', 'ehkrabs', 'Eugene H. Krabs')
+
Above we observe the :class:`_orm.Session` was first called upon to emit SQL,
so it created a new transaction and emitted the appropriate INSERT statements
diff --git a/doc/build/tutorial/orm_related_objects.rst b/doc/build/tutorial/orm_related_objects.rst
index 0df611e45..a6bb2b9a3 100644
--- a/doc/build/tutorial/orm_related_objects.rst
+++ b/doc/build/tutorial/orm_related_objects.rst
@@ -198,12 +198,11 @@ newly generated primary key of the ``user_account`` row is applied to the
>>> session.commit()
{opensql}INSERT INTO user_account (name, fullname) VALUES (?, ?)
[...] ('pkrabs', 'Pearl Krabs')
- INSERT INTO address (email_address, user_id) VALUES (?, ?)
- [...] ('pearl.krabs@gmail.com', 6)
- INSERT INTO address (email_address, user_id) VALUES (?, ?)
- [...] ('pearl@aol.com', 6)
+ INSERT INTO address (email_address, user_id) VALUES (?, ?), (?, ?) RETURNING id
+ [...] ('pearl.krabs@gmail.com', 6, 'pearl@aol.com', 6)
COMMIT
+
.. _tutorial_loading_relationships:
Loading Relationships