
    -h                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   " S S\5      r\R>                  " SS5       " S S\5      5       r \R>                  " SS 5       " S! S"\5      5       r!\R>                  " SS#5       " S$ S%\5      5       r" " S& S'\RF                  \\\\\\\5
      r$ " S( S)\$5      r% " S* S+\%5      r& " S, S-\'5      r( " S. S/\(\%5      r) " S0 S1\(\$5      r*g2)3zd
Provide :class:`_expression.Insert`, :class:`_expression.Update` and
:class:`_expression.Delete`.

    )NullType   )	coercions)roles)util)_entity_namespace_key)_exclusive_against)_from_objects)_generative)ColumnCollection)CompileState)DialectKWArgs)
Executable)HasCompileState)BooleanClauseList)ClauseElement)Null)HasCTE)HasPrefixes)ReturnsRows)InternalTraversal   )exc)collections_abcc                       \ rS rSrSrSrSrSrSrSr	Sr
SrSrS r\S 5       r\S 5       r\S 5       r\S	 5       rS
 rS rS rS rS rS rSrg)DMLState%   TNFc                     [        5       eNNotImplementedErrorself	statementcompilerkws       gC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/sql/dml.py__init__DMLState.__init__0   s    !##    c                 H    UR                   R                  UR                   S.$ )N)nametable)r-   r,   )clsr$   s     r'   get_entity_descriptionDMLState.get_entity_description3   s    !,,yGGr*   c                 v    UR                    Vs/ s H  nUR                  UR                  US.PM     sn$ s  snf )N)r,   typeexpr)_all_selected_columnskeyr2   )r.   r$   cs      r'   !get_returning_column_descriptions*DMLState.get_returning_column_descriptions7   sF     44
 5	 
 5
 	
 
s   $6c                 .    U R                   R                  $ r   )r$   r-   r#   s    r'   	dml_tableDMLState.dml_tableB   s    ~~###r*   c                     U VVs/ s HW  u  p4[         R                  " [        R                  U5      [         R                  " [        R                  U[        5       SS94PMY     snn$ s  snnf )NT)type_is_crud)r   expectr   DMLColumnRoleExpressionElementRoler   )r.   r$   kv_iteratorkvs        r'   _get_crud_kv_pairsDMLState._get_crud_kv_pairsF   si     $
 $   !4!4a8  //"* 	 $
 	
 
s   AA(c                 r   / n[        [        R                  " UR                  5      5      nUS   1nUR                   Ha  n[        U5       HO  nUR                  UR                  5      (       d  UR                  U5        UR                  UR                  5        MQ     Mc     UR                  USS  5        U$ )Nr   r   )listsql_utiltables_from_leftmostr-   _where_criteriar
   intersection_cloned_setappendupdateextend)r#   r$   froms
all_tablesseencrititems          r'   _make_extra_fromsDMLState._make_extra_fromsU   s    (77	HI
1--D%d+(()9)9::LL&D,,- , . 	Z^$r*   c                    UR                   (       d1  [        R                  " SUR                  R	                  5       -  5      eUR
                   H  nU VVVs/ s Hd  n[        U[        R                  5      (       a@  [        UR                  R                  U5       VVs0 s H  u  pEUR                  U_M     snnOUPMf     nnnnU R                  (       a*  SU l        SU l        X`l        U R                  S   U l        M  U R                  (       d  U R#                  5         M  U R                  R%                  U5        M     g s  snnf s  snnnf )Nz6%s construct does not support multiple parameter sets.FTr   )_supports_multi_parametersr   InvalidRequestError__visit_name__upper_multi_values
isinstancer   Sequencezipr-   r6   r5   _no_parameters_has_multi_parameters_multi_parameters_dict_parameters_cant_mix_formats_errorrQ   )r#   r$   
parametersparameter_setr6   valuemulti_parameterss          r'   _process_multi_valuesDMLState._process_multi_valuesd   s-   33))+-6-E-E-K-K-MN 
 $11J &0  &0M m_-E-EFF %(	(9(9=$I$I EE5L$I
 ## &0    ""&+#-1*)9&(,(>(>q(A%//,,.&&--.>?' 2 s   AE
 E9
E
E
c                     U R                   (       a   SU l        UR                  U l        SU l         g U R                  (       a  U R	                  5         g g )NF)rb   rc   _valuesre   rf   )r#   r$   s     r'   _process_valuesDMLState._process_values   sC    ).D&$-$5$5D!"'D''((* (r*   c                 ,   UR                   nU R                  (       a:  SU l        [        U5      U l        X l         U VVs/ s H  u  p4UPM	     snnU l        g U R
                  (       a  U R                  5         g [        R                  " S5      es  snnf )NFzQCan only invoke ordered_values() once, and not mixed with any other values() call)	_ordered_valuesrb   dictre   _parameter_orderingrc   rf   r   r[   )r#   r$   rg   r5   ri   s        r'   _process_ordered_values DMLState._process_ordered_values   s}    ..
"'D$($4D!#- >H'Ij
j'ID$''((*))/ 	 (Js    Bc           	          UR                    Vs0 s H0  n[        R                  " [        R                  USS9[        5       _M2     nnU R                  (       a  SU l        X0l        g  S5       es  snf )NT)as_keyFz%This statement already has parameters)_select_namesr   r@   r   rA   r   rb   re   )r#   r$   r,   rg   s       r'   _process_select_valuesDMLState._process_select_values   sr     "//
/ U00$tDdfL/ 	 

 "'D$.! BAA5
s   7A.c                 .    [         R                  " S5      e)NzCan't mix single and multiple VALUES formats in one INSERT statement; one style appends to a list while the other replaces values, so the intent is ambiguous.)r   r[   r:   s    r'   rf    DMLState._cant_mix_formats_error   s    %%
 	
r*   )re   rc   rd   rb   rr   rt   )__name__
__module____qualname____firstlineno__rb   re   rd   rr   rt   rc   isupdateisdeleteisinsertr(   classmethodr/   r7   propertyr;   rF   rW   rk   ro   ru   rz   rf   __static_attributes__ r*   r'   r   r   %   s    NO!HHH$ H H 
 
 $ $ 
 
@8+ B
r*   r   defaultinsertc                   F    \ rS rSrSrSrS r\R                  S 5       r	Sr
g)InsertDMLState   TFc                     Xl         SU l        UR                  (       a  U R                  U5        UR                  b  U R                  U5        UR                  (       a  U R                  U5        g g NT)r$   r   ry   rz   rn   ro   r^   rk   r"   s       r'   r(   InsertDMLState.__init__   s[    """''	2(  +""&&y1 #r*   c                     U R                    Vs/ s H(  n[        R                  " [        R                  U5      PM*     sn$ s  snf r   )re   r   expect_as_keyr   rA   )r#   cols     r'   _insert_col_keysInsertDMLState._insert_col_keys   sB    
 ,,
, ##E$7$7=,
 	
 
s   /A)r   r$   N)r~   r   r   r   r   include_table_with_column_exprsr(   r   memoized_propertyr   r   r   r*   r'   r   r      s,    H&+#	2 

 
r*   r   rP   c                   "    \ rS rSrSrSrS rSrg)UpdateDMLState   TFc                    Xl         SU l        UR                  U l        UR                  b  U R	                  U5        OAUR
                  b  U R                  U5        O"UR                  (       a  U R                  U5        U R                  U5      =U l
        nU=(       a    U R                  =U l        nU=(       a    UR                  U l        g r   )r$   r   _preserve_parameter_orderrr   ru   rn   ro   r^   rk   rW   _extra_fromsre   is_multitable'render_table_with_column_in_update_fromr   )r#   r$   r%   r&   efmts         r'   r(   UpdateDMLState.__init__   s    ")2)L)L&$$0((3*  +$$&&y1!%!7!7	!BBB"$">)>)>>RC8CC 	,r*   )r   r   r   r   r   r$   N)r~   r   r   r   r   r   r(   r   r   r*   r'   r   r      s    H&+#
r*   r   deletec                       \ rS rSrSrS rSrg)DeleteDMLState   Tc                 J    Xl         SU l        U R                  U5      U l        g r   )r$   r   rW   r   r"   s       r'   r(   DeleteDMLState.__init__   s!    " 229=r*   )r   r   r$   N)r~   r   r   r   r   r(   r   r   r*   r'   r   r      s    H>r*   r   c                   @   \ rS rSrSrSr\R                  R                  SS05      r\	R                  " 5       rSrSrSrSrSr\S	 5       rS
 rS r\S 5       rS rS rS r\" \\5      r\S 5       r\S 5       r\S 5       r\SS j5       r\S 5       r\S 5       r Sr!g)
UpdateBase   zDForm the base for ``INSERT``, ``UPDATE``, and ``DELETE`` statements.update_base
autocommitTFNr   c                     [        SSSSSSSSS	9n[        R                  " S0 U Vs0 s H  nUS
XE   SU-  SU-  S.-  4_M     snD6$ s  snf )NzThe :paramref:`%(func)s.whereclause` parameter will be removed in SQLAlchemy 2.0.  Please refer to the :meth:`%(classname)s.where` method.zThe :paramref:`%(func)s.values` parameter will be removed in SQLAlchemy 2.0.  Please refer to the :meth:`%(classname)s.values` method.zuThe :paramref:`%(func)s.bind` parameter will be removed in SQLAlchemy 2.0.  Please use explicit connection execution.zThe :paramref:`%(func)s.inline` parameter will be removed in SQLAlchemy 2.0.  Please use the :meth:`%(classname)s.inline` method.zThe :paramref:`%(func)s.prefixes parameter will be removed in SQLAlchemy 2.0.  Please use the :meth:`%(classname)s.prefix_with` method.zThe :paramref:`%(func)s.return_defaults` parameter will be removed in SQLAlchemy 2.0.  Please use the :meth:`%(classname)s.return_defaults` method.zThe :paramref:`%(func)s.returning` parameter will be removed in SQLAlchemy 2.0.  Please use the :meth:`%(classname)s.returning`` method.zThe :paramref:`%(func)s.preserve_parameter_order` parameter will be removed in SQLAlchemy 2.0.   Use the :meth:`%(classname)s.ordered_values` method with a list of tuples. )whereclausevaluesbindinlineprefixesreturn_defaults	returningpreserve_parameter_orderz2.0z_expression.%s)func	classnamer   )rs   r   deprecated_params)r.   fn_nameclsnamenamesparam_to_method_lookupr,   s         r'   _constructor_20_deprecations'UpdateBase._constructor_20_deprecations  s     "&67
M7@
;
Q-"
^ %% 
 "
 "D *0 07 :%5%?  "

 	

s   A	c                 d   ^ TR                   R                  U4S jU R                   5       5        g )Nc              3   D   >#    U  H  oR                  T5      v   M     g 7fr   )_make_proxy).0r   
fromclauses     r'   	<genexpr>AUpdateBase._generate_fromclause_column_proxies.<locals>.<genexpr>F  s      4
3BCOOJ''?s    )_columns_populate_separate_keys
_returning)r#   r   s    `r'   #_generate_fromclause_column_proxies.UpdateBase._generate_fromclause_column_proxiesE  s(    33 4
37??4
 	
r*   c                     [        S5      e)zSet the parameters for the statement.

This method raises ``NotImplementedError`` on the base class,
and is overridden by :class:`.ValuesBase` to provide the
SET/VALUES clause of UPDATE and INSERT.

zparams() is not supported for INSERT/UPDATE/DELETE statements. To set the values for an INSERT or UPDATE statement, use stmt.values(**parameters).r    )r#   argr&   s      r'   paramsUpdateBase.paramsJ  s     "*
 	
r*   c                 &    U R                  U5        g)zAdd dialect options to this INSERT/UPDATE/DELETE object.

e.g.::

    upd = table.update().dialect_options(mysql_limit=10)

.. versionadded: 1.4 - this method supersedes the dialect options
   associated with the constructor.


N)_validate_dialect_kwargs)r#   opts     r'   with_dialect_optionsUpdateBase.with_dialect_optionsX  s     	%%c*r*   c                     [         R                  " SU R                  R                  -  5        U R	                  U5        g )NzPassing dialect keyword arguments directly to the %s constructor is deprecated and will be removed in SQLAlchemy 2.0.  Please use the ``with_dialect_options()`` method.)r   warn_deprecated_20	__class__r~   r   )r#   
dialect_kws     r'   #_validate_dialect_kwargs_deprecated.UpdateBase._validate_dialect_kwargs_deprecatedg  s:    F ~~&&(	
 	%%j1r*   c                 T    U R                   =(       d    U R                  R                  $ )zeReturn a 'bind' linked to this :class:`.UpdateBase`
or a :class:`_schema.Table` associated with it.

)_bindr-   r   r:   s    r'   r   UpdateBase.bindp  s    
 zz,TZZ__,r*   c                     Xl         g r   )r   )r#   r   s     r'   	_set_bindUpdateBase._set_bindw  s    
r*   c                     U R                   (       a  [        R                  " S5      eU =R                  [	        S U 5       5      -  sl        g)a
  Add a :term:`RETURNING` or equivalent clause to this statement.

e.g.:

.. sourcecode:: pycon+sql

    >>> stmt = (
    ...     table.update()
    ...     .where(table.c.data == "value")
    ...     .values(status="X")
    ...     .returning(table.c.server_flag, table.c.updated_timestamp)
    ... )
    >>> print(stmt)
    UPDATE some_table SET status=:status
    WHERE some_table.data = :data_1
    RETURNING some_table.server_flag, some_table.updated_timestamp

The method may be invoked multiple times to add new entries to the
list of expressions to be returned.

.. versionadded:: 1.4.0b2 The method may be invoked multiple times to
 add new entries to the list of expressions to be returned.

The given collection of column expressions should be derived from the
table that is the target of the INSERT, UPDATE, or DELETE.  While
:class:`_schema.Column` objects are typical, the elements can also be
expressions:

.. sourcecode:: pycon+sql

    >>> stmt = table.insert().returning(
    ...     (table.c.first_name + " " + table.c.last_name).label("fullname")
    ... )
    >>> print(stmt)
    INSERT INTO some_table (first_name, last_name)
    VALUES (:first_name, :last_name)
    RETURNING some_table.first_name || :first_name_1 || some_table.last_name AS fullname

Upon compilation, a RETURNING clause, or database equivalent,
will be rendered within the statement.   For INSERT and UPDATE,
the values are the newly inserted/updated values.  For DELETE,
the values are those of the rows which were deleted.

Upon execution, the values of the columns to be returned are made
available via the result set and can be iterated using
:meth:`_engine.CursorResult.fetchone` and similar.
For DBAPIs which do not
natively support returning values (i.e. cx_oracle), SQLAlchemy will
approximate this behavior at the result level so that a reasonable
amount of behavioral neutrality is provided.

Note that not all databases/DBAPIs
support RETURNING.   For those backends with no support,
an exception is raised upon compilation and/or execution.
For those who do support it, the functionality across backends
varies greatly, including restrictions on executemany()
and other statements which return multiple rows. Please
read the documentation notes for the database in use in
order to determine the availability of RETURNING.

.. seealso::

  :meth:`.ValuesBase.return_defaults` - an alternative method tailored
  towards efficient fetching of server-side defaults and triggers
  for single-row INSERTs or UPDATEs.

  :ref:`tutorial_insert_returning` - in the :ref:`unified_tutorial`

z9return_defaults() is already configured on this statementc              3   l   #    U  H*  n[         R                  " [        R                  U5      v   M,     g 7fr   )r   r@   r   ColumnsClauseRoler   r6   s     r'   r   'UpdateBase.returning.<locals>.<genexpr>  s)      !
BFQIU44a88$s   24N)_return_defaultsr   r[   r   tupler#   colss     r'   r   UpdateBase.returning|  sH    N   ))K  	5 !
BF!
 
 	
r*   c                     U R                   $ r   )r   r:   s    r'   r4    UpdateBase._all_selected_columns  s    r*   c                 V    [        S U R                   5       5      R                  5       $ )z`Return the RETURNING columns as a column collection for this
statement.

.. versionadded:: 1.4

c              3   <   #    U  H  oR                   U4v   M     g 7fr   )r5   r   s     r'   r   .UpdateBase.exported_columns.<locals>.<genexpr>  s       
 :1UUAJ :s   )r   r4   as_immutabler:   s    r'   exported_columnsUpdateBase.exported_columns  s+        
 $ : : 
 

,.	r*   c                 h    Uc  U R                   nU R                  R                  X#4U05      U l        g)ab  Add a table hint for a single table to this
INSERT/UPDATE/DELETE statement.

.. note::

 :meth:`.UpdateBase.with_hint` currently applies only to
 Microsoft SQL Server.  For MySQL INSERT/UPDATE/DELETE hints, use
 :meth:`.UpdateBase.prefix_with`.

The text of the hint is rendered in the appropriate
location for the database backend in use, relative
to the :class:`_schema.Table` that is the subject of this
statement, or optionally to that of the given
:class:`_schema.Table` passed as the ``selectable`` argument.

The ``dialect_name`` option will limit the rendering of a particular
hint to a particular backend. Such as, to add a hint
that only takes effect for SQL Server::

    mytable.insert().with_hint("WITH (PAGLOCK)", dialect_name="mssql")

:param text: Text of the hint.
:param selectable: optional :class:`_schema.Table` that specifies
 an element of the FROM clause within an UPDATE or DELETE
 to be the subject of the hint - applies only to certain backends.
:param dialect_name: defaults to ``*``, if specified as the name
 of a particular dialect, will apply these hints only when
 that dialect is in use.
N)r-   _hintsunion)r#   text
selectabledialect_names       r'   	with_hintUpdateBase.with_hint  s1    > Jkk''*)CT(JKr*   c                 P    [         R                  U 5      R                  nU" U 5      $ )a  Return a :term:`plugin-enabled` description of the table and/or
entity which this DML construct is operating against.

This attribute is generally useful when using the ORM, as an
extended structure which includes information about mapped
entities is returned.  The section :ref:`queryguide_inspection`
contains more background.

For a Core statement, the structure returned by this accessor
is derived from the :attr:`.UpdateBase.table` attribute, and
refers to the :class:`.Table` being inserted, updated, or deleted::

    >>> stmt = insert(user_table)
    >>> stmt.entity_description
    {
        "name": "user_table",
        "table": Table("user_table", ...)
    }

.. versionadded:: 1.4.33

.. seealso::

    :attr:`.UpdateBase.returning_column_descriptions`

    :attr:`.Select.column_descriptions` - entity information for
    a :func:`.select` construct

    :ref:`queryguide_inspection` - ORM background

)r   get_plugin_classr/   r#   meths     r'   entity_descriptionUpdateBase.entity_description   s%    B ((.EEDzr*   c                 P    [         R                  U 5      R                  nU" U 5      $ )a  Return a :term:`plugin-enabled` description of the columns
which this DML construct is RETURNING against, in other words
the expressions established as part of :meth:`.UpdateBase.returning`.

This attribute is generally useful when using the ORM, as an
extended structure which includes information about mapped
entities is returned.  The section :ref:`queryguide_inspection`
contains more background.

For a Core statement, the structure returned by this accessor is
derived from the same objects that are returned by the
:attr:`.UpdateBase.exported_columns` accessor::

    >>> stmt = insert(user_table).returning(user_table.c.id, user_table.c.name)
    >>> stmt.entity_description
    [
        {
            "name": "id",
            "type": Integer,
            "expr": Column("id", Integer(), table=<user>, ...)
        },
        {
            "name": "name",
            "type": String(),
            "expr": Column("name", String(), table=<user>, ...)
        },
    ]

.. versionadded:: 1.4.33

.. seealso::

    :attr:`.UpdateBase.entity_description`

    :attr:`.Select.column_descriptions` - entity information for
    a :func:`.select` construct

    :ref:`queryguide_inspection` - ORM background

)r   r   r7   r   s     r'   returning_column_descriptions(UpdateBase.returning_column_descriptions$  s-    T ((

+
+ 	 Dzr*   )r   r   )N*)"r~   r   r   r   __doc__r\   r   _execution_optionsr   r   immutabledictr   named_with_columnr   _return_defaults_columnsr   is_dmlr   r   r   r   r   r   r   r   r   r   r   r4   r   r   r   r  r   r   r*   r'   r   r      s#    O"N#66<<	t !F#JF=
 =
~


 + +2- D)$DL
 L
\   
 
 !L !LF ! !F , ,r*   r   c                       \ rS rSrSrSrSrSrSrSr	Sr
SrSrSrSrS r\\" SS	S
SS.S9S 5       5       r\\" SSS0S\0S9S 5       5       rSrg)
ValuesBaseiT  zPSupplies support for :meth:`.ValuesBase.values` to
INSERT and UPDATE constructs.values_baseFNr   c                     [         R                  " [        R                  XS9U l        Ub  U R
                  R                  X5        U(       a  U R                  U5        g g )Napply_propagate_attrs)r   r@   r   DMLTableRoler-   r   non_generative_setup_prefixes)r#   r-   r   r   s       r'   r(   ValuesBase.__init__f  sO    %%

 KK&&t4  * r*   ry   rr   z,This construct already inserts from a SELECT1This statement already has ordered values present)ry   rr   )msgsc                 <   U(       Ga4  US   nU(       a  [         R                  " S5      e[        U5      S:  a  [         R                  " S5      eU R                  (       d  [	        U[
        R                  5      (       a  U(       a:  [	        US   [        [        [        45      (       a  U =R                  U4-  sl
        g[        U R                  R                  U5       VVs0 s H  u  pEUR                  U_M     nnnO[U R                  (       a*  [	        U[
        R                  5      (       d  [        S5      eOUnU(       a  [         R                  " S5      e[         R#                  U 5      R$                  nU R                  (       a  U" X5      U l        gU" XR)                  5       5       VVs0 s H  u  pxXx_M	     nnnU R*                  (       a!  U R*                  R-                  U5      U l        g[.        R0                  " U5      U l        gs  snnf s  snnf )a  Specify a fixed VALUES clause for an INSERT statement, or the SET
clause for an UPDATE.

Note that the :class:`_expression.Insert` and
:class:`_expression.Update`
constructs support
per-execution time formatting of the VALUES and/or SET clauses,
based on the arguments passed to :meth:`_engine.Connection.execute`.
However, the :meth:`.ValuesBase.values` method can be used to "fix" a
particular set of parameters into the statement.

Multiple calls to :meth:`.ValuesBase.values` will produce a new
construct, each one with the parameter list modified to include
the new parameters sent.  In the typical case of a single
dictionary of parameters, the newly passed keys will replace
the same keys in the previous construct.  In the case of a list-based
"multiple values" construct, each new list of values is extended
onto the existing list of values.

:param \**kwargs: key value pairs representing the string key
  of a :class:`_schema.Column`
  mapped to the value to be rendered into the
  VALUES or SET clause::

        users.insert().values(name="some name")

        users.update().where(users.c.id==5).values(name="some name")

:param \*args: As an alternative to passing key/value parameters,
 a dictionary, tuple, or list of dictionaries or tuples can be passed
 as a single positional argument in order to form the VALUES or
 SET clause of the statement.  The forms that are accepted vary
 based on whether this is an :class:`_expression.Insert` or an
 :class:`_expression.Update` construct.

 For either an :class:`_expression.Insert` or
 :class:`_expression.Update`
 construct, a single dictionary can be passed, which works the same as
 that of the kwargs form::

    users.insert().values({"name": "some name"})

    users.update().values({"name": "some new name"})

 Also for either form but more typically for the
 :class:`_expression.Insert` construct, a tuple that contains an
 entry for every column in the table is also accepted::

    users.insert().values((5, "some name"))

 The :class:`_expression.Insert` construct also supports being
 passed a list of dictionaries or full-table-tuples, which on the
 server will render the less common SQL syntax of "multiple values" -
 this syntax is supported on backends such as SQLite, PostgreSQL,
 MySQL, but not necessarily others::

    users.insert().values([
                        {"name": "some name"},
                        {"name": "some other name"},
                        {"name": "yet another name"},
                    ])

 The above form would render a multiple VALUES statement similar to::

        INSERT INTO users (name) VALUES
                        (:name_1),
                        (:name_2),
                        (:name_3)

 It is essential to note that **passing multiple values is
 NOT the same as using traditional executemany() form**.  The above
 syntax is a **special** syntax not typically used.  To emit an
 INSERT statement against multiple rows, the normal method is
 to pass a multiple values list to the
 :meth:`_engine.Connection.execute`
 method, which is supported by all database backends and is generally
 more efficient for a very large number of parameters.

   .. seealso::

       :ref:`tutorial_multiple_parameters` - an introduction to
       the traditional Core method of multiple parameter set
       invocation for INSERTs and other statements.

   .. versionchanged:: 1.0.0 an INSERT that uses a multiple-VALUES
      clause, even a list of length one,
      implies that the :paramref:`_expression.Insert.inline`
      flag is set to
      True, indicating that the statement will not attempt to fetch
      the "last inserted primary key" or other defaults.  The
      statement deals with an arbitrary number of rows, so the
      :attr:`_engine.CursorResult.inserted_primary_key`
      accessor does not
      apply.

   .. versionchanged:: 1.0.0 A multiple-VALUES INSERT now supports
      columns with Python side default values and callables in the
      same way as that of an "executemany" style of invocation; the
      callable is invoked for each row.   See :ref:`bug_3288`
      for other details.

  The UPDATE construct also supports rendering the SET parameters
  in a specific order.  For this feature refer to the
  :meth:`_expression.Update.ordered_values` method.

   .. seealso::

      :meth:`_expression.Update.ordered_values`


r   z;Can't pass positional and kwargs to values() simultaneouslyr   zWOnly a single dictionary/tuple or list of dictionaries/tuples is accepted positionally.NzOWhen preserve_parameter_order is True, values() only accepts a list of 2-tuples)r   ArgumentErrorlenr   r_   r   r`   rI   rs   r   r^   ra   r-   r6   r5   
ValueErrorr   r   rF   rr   itemsrn   r   r   r  )	r#   argskwargsr   r6   ri   kv_generatorrD   rE   s	            r'   r   ValuesBase.valueso  s   t  q'C''%  TQ''D 
 33
_--9 9 :c!ftT5.ABB&&3&0& 58

c4JK4Jquue|4JK//
_--9 9 !?  C''D   006II))#/#:D $0yy{$CD$CDA14$CCD||#||11#6#11#6E L< Es   $H3Hr   z1RETURNING is already configured on this statement)r  defaultsc                     SU l         Xl        g)a  Make use of a :term:`RETURNING` clause for the purpose
of fetching server-side expressions and defaults.

E.g.::

    stmt = table.insert().values(data='newdata').return_defaults()

    result = connection.execute(stmt)

    server_created_at = result.returned_defaults['created_at']

When used against a backend that supports RETURNING, all column
values generated by SQL expression or server-side-default will be
added to any existing RETURNING clause, provided that
:meth:`.UpdateBase.returning` is not used simultaneously.  The column
values will then be available on the result using the
:attr:`_engine.CursorResult.returned_defaults` accessor as
a dictionary,
referring to values keyed to the :class:`_schema.Column`
object as well as
its ``.key``.

This method differs from :meth:`.UpdateBase.returning` in these ways:

1. :meth:`.ValuesBase.return_defaults` is only intended for use with an
   INSERT or an UPDATE statement that matches exactly one row per
   parameter set. While the RETURNING construct in the general sense
   supports multiple rows for a multi-row UPDATE or DELETE statement,
   or for special cases of INSERT that return multiple rows (e.g.
   INSERT from SELECT, multi-valued VALUES clause),
   :meth:`.ValuesBase.return_defaults` is intended only for an
   "ORM-style" single-row INSERT/UPDATE statement.  The row
   returned by the statement is also consumed implicitly when
   :meth:`.ValuesBase.return_defaults` is used.  By contrast,
   :meth:`.UpdateBase.returning` leaves the RETURNING result-set intact
   with a collection of any number of rows.

2. It is compatible with the existing logic to fetch auto-generated
   primary key values, also known as "implicit returning".  Backends
   that support RETURNING will automatically make use of RETURNING in
   order to fetch the value of newly generated primary keys; while the
   :meth:`.UpdateBase.returning` method circumvents this behavior,
   :meth:`.ValuesBase.return_defaults` leaves it intact.

3. It can be called against any backend.  Backends that don't support
   RETURNING will skip the usage of the feature, rather than raising
   an exception.  The return value of
   :attr:`_engine.CursorResult.returned_defaults` will be ``None``

4. An INSERT statement invoked with executemany() is supported if the
   backend database driver supports the
   ``insert_executemany_returning`` feature, currently this includes
   PostgreSQL with psycopg2.  When executemany is used, the
   :attr:`_engine.CursorResult.returned_defaults_rows` and
   :attr:`_engine.CursorResult.inserted_primary_key_rows` accessors
   will return the inserted defaults and primary keys.

   .. versionadded:: 1.4

:meth:`.ValuesBase.return_defaults` is used by the ORM to provide
an efficient implementation for the ``eager_defaults`` feature of
:func:`.mapper`.

:param cols: optional list of column key names or
 :class:`_schema.Column`
 objects.  If omitted, all column expressions evaluated on the server
 are added to the returning list.

.. versionadded:: 0.9.0

.. seealso::

    :meth:`.UpdateBase.returning`

    :attr:`_engine.CursorResult.returned_defaults`

    :attr:`_engine.CursorResult.returned_defaults_rows`

    :attr:`_engine.CursorResult.inserted_primary_key`

    :attr:`_engine.CursorResult.inserted_primary_key_rows`

TN)r   r	  r   s     r'   r   ValuesBase.return_defaults)  s    x !%(,%r*   )rr   r   r	  rn   r-   )r~   r   r   r   r  r\   rZ   r   select_post_values_clausern   r^   rr   ry   r   r(   r   r	   r   r   r   r   r*   r'   r  r  T  s    % #N!& %FGMOMJ+ K 
n7 n7` M
 
+U- U-r*   r  c                   .  ^  \ rS rSrSrSrSrSrSrSr	S\
R                  4S\
R                  4S	\
R                  4S
\
R                  4S\
R                  4S\
R                  4S\
R                  4S\
R                   4S\
R"                  4S\
R                  4S\
R                   4/\R&                  -   \R*                  -   \R.                  -   \R2                  -   r\R9                  SS / SQ5            SU 4S jj5       r\S 5       r\SS j5       r Sr!U =r"$ )Inserti  zRepresent an INSERT construct.

The :class:`_expression.Insert` object is created using the
:func:`_expression.insert()` function.

r   TNFr-   _inlinery   rn   r^   r#  r$  r   r   r   r	  )r   r   r   r   r   r   c                    > [         [        U ]  XU5        X@l        X0l        U(       a  X`l        U(       a  U R                  U5        U(       a$  SU l        [        U[        5      (       d  Xpl
        ggg)a  Construct an :class:`_expression.Insert` object.

E.g.::

    from sqlalchemy import insert

    stmt = (
        insert(user_table).
        values(name='username', fullname='Full Username')
    )

Similar functionality is available via the
:meth:`_expression.TableClause.insert` method on
:class:`_schema.Table`.

.. seealso::

    :ref:`tutorial_core_insert` - in the :ref:`unified_tutorial`


:param table: :class:`_expression.TableClause`
 which is the subject of the
 insert.

:param values: collection of values to be inserted; see
 :meth:`_expression.Insert.values`
 for a description of allowed formats here.
 Can be omitted entirely; a :class:`_expression.Insert` construct
 will also dynamically render the VALUES clause at execution time
 based on the parameters passed to :meth:`_engine.Connection.execute`.

:param inline: if True, no attempt will be made to retrieve the
 SQL-generated default values to be provided within the statement;
 in particular,
 this allows SQL expressions to be rendered 'inline' within the
 statement without the need to pre-execute them beforehand; for
 backends that support "returning", this turns off the "implicit
 returning" feature for the statement.

If both :paramref:`_expression.Insert.values` and compile-time bind
parameters are present, the compile-time bind parameters override the
information specified within :paramref:`_expression.Insert.values` on a
per-key basis.

The keys within :paramref:`_expression.Insert.values` can be either
:class:`~sqlalchemy.schema.Column` objects or their string
identifiers. Each key may reference one of:

* a literal data value (i.e. string, number, etc.);
* a Column object;
* a SELECT statement.

If a ``SELECT`` statement is specified which references this
``INSERT`` statement's table, the statement will be correlated
against the ``INSERT`` statement.

.. seealso::

    :ref:`tutorial_core_insert` - in the :ref:`unified_tutorial`

TN)superr&  r(   r   r'  r   r   r   r_   boolr	  )
r#   r-   r   r   r   r   r   r   r   r   s
            r'   r(   Insert.__init__  sb    h 	fd$UH=
'O44Z@$(D!ot440?- 5 r*   c                     SU l         g)a;  Make this :class:`_expression.Insert` construct "inline" .

When set, no attempt will be made to retrieve the
SQL-generated default values to be provided within the statement;
in particular,
this allows SQL expressions to be rendered 'inline' within the
statement without the need to pre-execute them beforehand; for
backends that support "returning", this turns off the "implicit
returning" feature for the statement.


.. versionchanged:: 1.4 the :paramref:`_expression.Insert.inline`
   parameter
   is now superseded by the :meth:`_expression.Insert.inline` method.

TNr'  r:   s    r'   r   Insert.inline  s    $ r*   c                     U R                   (       a  [        R                  " S5      eXl        SU l        X0l        [        R                  " [        R                  U5      U l
        g)a  Return a new :class:`_expression.Insert` construct which represents
an ``INSERT...FROM SELECT`` statement.

e.g.::

    sel = select(table1.c.a, table1.c.b).where(table1.c.c > 5)
    ins = table2.insert().from_select(['a', 'b'], sel)

:param names: a sequence of string column names or
 :class:`_schema.Column`
 objects representing the target columns.
:param select: a :func:`_expression.select` construct,
 :class:`_expression.FromClause`
 or other construct which resolves into a
 :class:`_expression.FromClause`,
 such as an ORM :class:`_query.Query` object, etc.  The order of
 columns returned from this FROM clause should correspond to the
 order of columns sent as the ``names`` parameter;  while this
 is not checked before passing along to the database, the database
 would normally raise an exception if these column lists don't
 correspond.
:param include_defaults: if True, non-server default values and
 SQL expressions as specified on :class:`_schema.Column` objects
 (as documented in :ref:`metadata_defaults_toplevel`) not
 otherwise specified in the list of names will be rendered
 into the INSERT and SELECT statements, so that these values are also
 included in the data to be inserted.

 .. note:: A Python-side default that uses a Python callable function
    will only be invoked **once** for the whole statement, and **not
    per row**.

 .. versionadded:: 1.0.0 - :meth:`_expression.Insert.from_select`
    now renders
    Python-side and SQL expression column defaults into the
    SELECT statement for columns otherwise not included in the
    list of column names.

.. versionchanged:: 1.0.0 an INSERT that uses FROM SELECT
   implies that the :paramref:`_expression.insert.inline`
   flag is set to
   True, indicating that the statement will not attempt to fetch
   the "last inserted primary key" or other defaults.  The statement
   deals with an arbitrary number of rows, so the
   :attr:`_engine.CursorResult.inserted_primary_key`
   accessor does not apply.

z0This construct already inserts value expressionsTN)rn   r   r[   ry   r'  #include_insert_from_select_defaultsr   r@   r   DMLSelectRoler#  )r#   r   r#  include_defaultss       r'   from_selectInsert.from_select&  sQ    f <<))B  #3C0&&u':':FCr*   )r   r'  r   r	  r   ry   r0  r#  )NFNNNF)T)#r~   r   r   r   r  r\   rZ   r#  r0  	is_insertr   dp_clauseelement
dp_booleandp_string_listdp_dml_valuesdp_dml_multi_valuesdp_clauseelement_tupledp_table_hint_listr    _has_prefixes_traverse_internalsr   "_dialect_kwargs_traverse_internalsr   _executable_traverse_internalsr   _has_ctes_traverse_internals_traverse_internalsr  r   r(   r   r   r3  r   __classcell__r   s   @r'   r&  r&    s    N!%F*/'I '889)445/>>?)778/CCD(99:"$5$F$FG,CCD(;;<!2!=!=>*!88	
  
6
6!	7" 
:
:#	;$ 
3
3%	4& 
-
-'	. . ,,	
 S@S@j  & :D :Dr*   r&  c                   J    \ rS rSrSr\S 5       rS rS rS r	\
S 5       rSrg)	DMLWhereBaseid  r   c                     U H>  n[         R                  " [        R                  U5      nU =R                  U4-  sl        M@     g)ap  Return a new construct with the given expression(s) added to
its WHERE clause, joined to the existing clause via AND, if any.

Both :meth:`_dml.Update.where` and :meth:`_dml.Delete.where`
support multiple-table forms, including database-specific
``UPDATE...FROM`` as well as ``DELETE..USING``.  For backends that
don't have multiple-table support, a backend agnostic approach
to using multiple tables is to make use of correlated subqueries.
See the linked tutorial sections below for examples.

.. seealso::

    :ref:`tutorial_correlated_updates`

    :ref:`tutorial_update_from`

    :ref:`tutorial_multi_table_deletes`

N)r   r@   r   WhereHavingRolerL   )r#   r   	criterionwhere_criterias       r'   whereDMLWhereBase.whereg  s:    , %I&--e.C.CYON  ^$55  %r*   c                      U R                   " U6 $ )zRA synonym for the :meth:`_dml.DMLWhereBase.where` method.

.. versionadded:: 1.4

)rJ  )r#   criterias     r'   filterDMLWhereBase.filter  s     zz8$$r*   c                     U R                   $ r   )r-   r:   s    r'   _filter_by_zeroDMLWhereBase._filter_by_zero  s    zzr*   c                     U R                  5       nUR                  5        VVs/ s H  u  p4[        X#5      U:H  PM     nnnU R                  " U6 $ s  snnf )zGapply the given filtering criterion as a WHERE clause
to this select.

)rQ  r  r   rN  )r#   r  from_entityr5   ri   clausess         r'   	filter_byDMLWhereBase.filter_by  s\    
 **, %lln
,
 "+3u<, 	 
 {{G$$	
s   Ac                 B    [         R                  " U R                  5      $ )zReturn the completed WHERE clause for this :class:`.DMLWhereBase`
statement.

This assembles the current collection of WHERE criteria
into a single :class:`_expression.BooleanClauseList` construct.


.. versionadded:: 1.4

)r   _construct_for_whereclauserL   r:   s    r'   r   DMLWhereBase.whereclause  s      !;;  
 	
r*   N)r~   r   r   r   rL   r   rJ  rN  rQ  rV  r   r   r   r   r*   r'   rE  rE  d  s<    O6 62%% 
 
r*   rE  c            
         ^  \ rS rSrSrSrSrS\R                  4S\R                  4S\R                  4S\R                  4S	\R                  4S
\R                  4S\R                  4S\R                  4S\R                  4/	\R                  -   \R"                  -   \R&                  -   \R*                  -   r\R1                  SS / SQ5              SU 4S jj5       r\S 5       r\S 5       rSrU =r$ )Updatei  zRepresent an Update construct.

The :class:`_expression.Update` object is created using the
:func:`_expression.update()` function.

rP   Tr-   rL   r'  rr   rn   r   r   r   r	  )r   r   r   r   r   r   r   r   c
                    > Xl         [        [        U ]  XU5        XPl        U(       a  Xpl        Ub9  U =R                  [        R                  " [        R                  U5      4-  sl        X@l        U
(       a  U R                  U
5        Xl        g)a  Construct an :class:`_expression.Update` object.

E.g.::

    from sqlalchemy import update

    stmt = (
        update(user_table).
        where(user_table.c.id == 5).
        values(name='user #5')
    )

Similar functionality is available via the
:meth:`_expression.TableClause.update` method on
:class:`_schema.Table`.

:param table: A :class:`_schema.Table`
 object representing the database
 table to be updated.

:param whereclause: Optional SQL expression describing the ``WHERE``
 condition of the ``UPDATE`` statement; is equivalent to using the
 more modern :meth:`~Update.where()` method to specify the ``WHERE``
 clause.

:param values:
  Optional dictionary which specifies the ``SET`` conditions of the
  ``UPDATE``.  If left as ``None``, the ``SET``
  conditions are determined from those parameters passed to the
  statement during the execution and/or compilation of the
  statement.   When compiled standalone without any parameters,
  the ``SET`` clause generates for all columns.

  Modern applications may prefer to use the generative
  :meth:`_expression.Update.values` method to set the values of the
  UPDATE statement.

:param inline:
  if True, SQL defaults present on :class:`_schema.Column` objects via
  the ``default`` keyword will be compiled 'inline' into the statement
  and not pre-executed.  This means that their values will not
  be available in the dictionary returned from
  :meth:`_engine.CursorResult.last_updated_params`.

:param preserve_parameter_order: if True, the update statement is
  expected to receive parameters **only** via the
  :meth:`_expression.Update.values` method,
  and they must be passed as a Python
  ``list`` of 2-tuples. The rendered UPDATE statement will emit the SET
  clause for each referenced column maintaining this order.

  .. versionadded:: 1.0.10

  .. seealso::

    :ref:`updates_order_parameters` - illustrates the
    :meth:`_expression.Update.ordered_values` method.

If both ``values`` and compile-time bind parameters are present, the
compile-time bind parameters override the information specified
within ``values`` on a per-key basis.

The keys within ``values`` can be either :class:`_schema.Column`
objects or their string identifiers (specifically the "key" of the
:class:`_schema.Column`, normally but not necessarily equivalent to
its "name").  Normally, the
:class:`_schema.Column` objects used here are expected to be
part of the target :class:`_schema.Table` that is the table
to be updated.  However when using MySQL, a multiple-table
UPDATE statement can refer to columns from any of
the tables referred to in the WHERE clause.

The values referred to in ``values`` are typically:

* a literal data value (i.e. string, number, etc.)
* a SQL expression, such as a related :class:`_schema.Column`,
  a scalar-returning :func:`_expression.select` construct,
  etc.

When combining :func:`_expression.select` constructs within the
values clause of an :func:`_expression.update`
construct, the subquery represented
by the :func:`_expression.select` should be *correlated* to the
parent table, that is, providing criterion which links the table inside
the subquery to the outer table being updated::

    users.update().values(
            name=select(addresses.c.email_address).\
                    where(addresses.c.user_id==users.c.id).\
                    scalar_subquery()
        )

.. seealso::

    :ref:`inserts_and_updates` - SQL Expression
    Language Tutorial


N)r   r)  r\  r(   r   r   rL   r   r@   r   rG  r'  r   r   )r#   r-   r   r   r   r   r   r   r   r   r   r   s              r'   r(   Update.__init__  s{    | *B&fd$UH=
'O"    !6!6D%   44Z@ /r*   c                     U R                   (       a  [        R                  " S5      eU R                  (       a  [        R                  " S5      e[        R                  U 5      R                  nU" X5      U l        g)ac  Specify the VALUES clause of this UPDATE statement with an explicit
parameter ordering that will be maintained in the SET clause of the
resulting UPDATE statement.

E.g.::

    stmt = table.update().ordered_values(
        ("name", "ed"), ("ident": "foo")
    )

.. seealso::

   :ref:`tutorial_parameter_ordered_updates` - full example of the
   :meth:`_expression.Update.ordered_values` method.

.. versionchanged:: 1.4 The :meth:`_expression.Update.ordered_values`
   method
   supersedes the
   :paramref:`_expression.update.preserve_parameter_order`
   parameter, which will be removed in SQLAlchemy 2.0.

z)This statement already has values presentr  N)rn   r   r  rr   r   r   rF   )r#   r  r  s      r'   ordered_valuesUpdate.ordered_valuesY  sg    0 <<##;  !!##C   006II+D7r*   c                     SU l         g)a  Make this :class:`_expression.Update` construct "inline" .

When set, SQL defaults present on :class:`_schema.Column`
objects via the
``default`` keyword will be compiled 'inline' into the statement and
not pre-executed.  This means that their values will not be available
in the dictionary returned from
:meth:`_engine.CursorResult.last_updated_params`.

.. versionchanged:: 1.4 the :paramref:`_expression.update.inline`
   parameter
   is now superseded by the :meth:`_expression.Update.inline` method.

TNr-  r:   s    r'   r   Update.inline}  s      r*   )r   r'  rr   r   r   r   )NNFNNNFF)r~   r   r   r   r  r\   	is_updater   r6  r;  r7  dp_dml_ordered_valuesr9  r<  r   r=  r   r>  r   r?  r   r@  rA  r  r   r(   r   r`  r   r   rB  rC  s   @r'   r\  r\    sY    NI '889 1 H HI)445 1 G GH)778,CCD(;;<!2!=!=>*!88	
 
6
6	7 
:
:	;  
3
3!	4" 
-
-#	. * ,,		
" !&|0|0| !8 !8F  r*   r\  c                   6   \ rS rSrSrSrSrS\R                  4S\R                  4S\R                  4S\R                  4/\R                  -   \R                  -   \R                   -   \R$                  -   r\R+                  SS / S	Q5          SS j5       rSrg
)Deletei  zRepresent a DELETE construct.

The :class:`_expression.Delete` object is created using the
:func:`_expression.delete()` function.

r   Tr-   rL   r   r   )r   r   r   r   r   Nc                 T   X0l         [        R                  " [        R                  XS9U l        U(       a  X@l        U(       a  U R                  U5        Ub9  U =R                  [        R                  " [        R                  U5      4-  sl        U(       a  U R                  U5        gg)a  Construct :class:`_expression.Delete` object.

E.g.::

    from sqlalchemy import delete

    stmt = (
        delete(user_table).
        where(user_table.c.id == 5)
    )

Similar functionality is available via the
:meth:`_expression.TableClause.delete` method on
:class:`_schema.Table`.

.. seealso::

    :ref:`inserts_and_updates` - in the
    :ref:`1.x tutorial <sqlexpression_toplevel>`

    :ref:`tutorial_core_update_delete` - in the :ref:`unified_tutorial`


:param table: The table to delete rows from.

:param whereclause: Optional SQL expression describing the ``WHERE``
 condition of the ``DELETE`` statement; is equivalent to using the
 more modern :meth:`~Delete.where()` method to specify the ``WHERE``
 clause.

.. seealso::

    :ref:`deletes` - SQL Expression Tutorial

r  N)r   r   r@   r   r  r-   r   r  rL   rG  r   )r#   r-   r   r   r   r   r   s          r'   r(   Delete.__init__  s    b 
%%

 'O  *"    !6!6D%   44Z@ r*   )r   r   r-   )NNNN)r~   r   r   r   r  r\   	is_deleter   r6  r;  r<  r   r=  r   r>  r   r?  r   r@  rA  r  r   r(   r   r   r*   r'   rg  rg    s     NI '889 1 H HI,CCD(;;<		
 
6
6	7 
:
:	; 
3
3	4 
-
-		.  ,,B <A
<Ar*   rg  N)+r  sqlalchemy.typesr    r   r   r   rJ   baser   r	   r
   r   r   r   r   r   r   elementsr   r   r   r   r   r   r   visitorsr   r   r   r   
plugin_forr   r   r   DMLRoler   r  r&  objectrE  r\  rg  r   r*   r'   <module>rs     sS  
 &    ' $   "    ! ' #   # # '   "G
| G
T H-
X 
 .
2 H-
X 
 .
, H->X > .>f	MM
fRr- r-j	XDZ XDvE
6 E
Pa\: aHZA\: ZAr*   