Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé
Classe « scoped_session »

Méthode sqlalchemy.orm.scoped_session.bulk_insert_mappings

Signature de la méthode bulk_insert_mappings

def bulk_insert_mappings(self, mapper: 'Mapper[Any]', mappings: 'Iterable[Dict[str, Any]]', return_defaults: 'bool' = False, render_nulls: 'bool' = False) -> 'None' 

Description

help(scoped_session.bulk_insert_mappings)

Perform a bulk insert of the given list of mapping dictionaries.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_orm.scoping.scoped_session` class.

.. legacy::

    This method is a legacy feature as of the 2.0 series of
    SQLAlchemy.   For modern bulk INSERT and UPDATE, see
    the sections :ref:`orm_queryguide_bulk_insert` and
    :ref:`orm_queryguide_bulk_update`.  The 2.0 API shares
    implementation details with this method and adds new features
    as well.

:param mapper: a mapped class, or the actual :class:`_orm.Mapper`
 object,
 representing the single kind of object represented within the mapping
 list.

:param mappings: a sequence of dictionaries, each one containing the
 state of the mapped row to be inserted, in terms of the attribute
 names on the mapped class.   If the mapping refers to multiple tables,
 such as a joined-inheritance mapping, each dictionary must contain all
 keys to be populated into all tables.

:param return_defaults: when True, the INSERT process will be altered
 to ensure that newly generated primary key values will be fetched.
 The rationale for this parameter is typically to enable
 :ref:`Joined Table Inheritance <joined_inheritance>` mappings to
 be bulk inserted.

 .. note:: for backends that don't support RETURNING, the
    :paramref:`_orm.Session.bulk_insert_mappings.return_defaults`
    parameter can significantly decrease performance as INSERT
    statements can no longer be batched.   See
    :ref:`engine_insertmanyvalues`
    for background on which backends are affected.

:param render_nulls: When True, a value of ``None`` will result
 in a NULL value being included in the INSERT statement, rather
 than the column being omitted from the INSERT.   This allows all
 the rows being INSERTed to have the identical set of columns which
 allows the full set of rows to be batched to the DBAPI.  Normally,
 each column-set that contains a different combination of NULL values
 than the previous row must omit a different series of columns from
 the rendered INSERT statement, which means it must be emitted as a
 separate statement.   By passing this flag, the full set of rows
 are guaranteed to be batchable into one batch; the cost however is
 that server-side defaults which are invoked by an omitted column will
 be skipped, so care must be taken to ensure that these are not
 necessary.

 .. warning::

    When this flag is set, **server side default SQL values will
    not be invoked** for those columns that are inserted as NULL;
    the NULL value will be sent explicitly.   Care must be taken
    to ensure that no server-side default functions need to be
    invoked for the operation as a whole.

.. seealso::

    :doc:`queryguide/dml`

    :meth:`.Session.bulk_save_objects`

    :meth:`.Session.bulk_update_mappings`




Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé