
    +h                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 d	d
l
mZ d	dlmZ  G d de      Z G d de      Z G d de      Z G d de      Z G d de	      Z G d dee      ZeZy)a  
.. dialect:: mssql+mxodbc
    :name: mxODBC
    :dbapi: mxodbc
    :connectstring: mssql+mxodbc://<username>:<password>@<dsnname>
    :url: https://www.egenix.com/

.. deprecated:: 1.4 The mxODBC DBAPI is deprecated and will be removed
   in a future version. Please use one of the supported DBAPIs to
   connect to mssql.

Execution Modes
---------------

mxODBC features two styles of statement execution, using the
``cursor.execute()`` and ``cursor.executedirect()`` methods (the second being
an extension to the DBAPI specification). The former makes use of a particular
API call specific to the SQL Server Native Client ODBC driver known
SQLDescribeParam, while the latter does not.

mxODBC apparently only makes repeated use of a single prepared statement
when SQLDescribeParam is used. The advantage to prepared statement reuse is
one of performance. The disadvantage is that SQLDescribeParam has a limited
set of scenarios in which bind parameters are understood, including that they
cannot be placed within the argument lists of function calls, anywhere outside
the FROM, or even within subqueries within the FROM clause - making the usage
of bind parameters within SELECT statements impossible for all but the most
simplistic statements.

For this reason, the mxODBC dialect uses the "native" mode by default only for
INSERT, UPDATE, and DELETE statements, and uses the escaped string mode for
all other statements.

This behavior can be controlled via
:meth:`~sqlalchemy.sql.expression.Executable.execution_options` using the
``native_odbc_execute`` flag with a value of ``True`` or ``False``, where a
value of ``True`` will unconditionally use native bind parameters and a value
of ``False`` will unconditionally use string-escaped parameters.

   )_MSDate)_MSDateTime)_MSTime)	MSDialect)	VARBINARY)_MSNumeric_pyodbc)MSExecutionContext_pyodbc   )types)MxODBCConnectorc                       e Zd ZdZy)_MSNumeric_mxodbcz#Include pyodbc's numeric processor.N__name__
__module____qualname____doc__     S/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/dialects/mssql/mxodbc.pyr   r   =   s    -r   r   c                       e Zd Zd Zy)_MSDate_mxodbcc                     d }|S )Nc                 X    | (| j                   d| j                  d| j                  S y )N-)yearmonthdayvalues    r   processz._MSDate_mxodbc.bind_processor.<locals>.processC   s$     %*ZZeiiHHr   r   selfdialectr!   s      r   bind_processorz_MSDate_mxodbc.bind_processorB       	 r   Nr   r   r   r%   r   r   r   r   r   A       r   r   c                       e Zd Zd Zy)_MSTime_mxodbcc                     d }|S )Nc                 X    | (| j                   d| j                  d| j                  S y )N:)hourminutesecondr   s    r   r!   z._MSTime_mxodbc.bind_processor.<locals>.processN   s$     %*ZZu||LLr   r   r"   s      r   r%   z_MSTime_mxodbc.bind_processorM   r&   r   Nr'   r   r   r   r*   r*   L   r(   r   r*   c                       e Zd ZdZd Zy)_VARBINARY_mxodbcz
    mxODBC Support for VARBINARY column types.

    This handles the special case for null VARBINARY values,
    which maps None values to the mx.ODBC.Manager.BinaryNull symbol.
    c                 \    j                   y j                   j                  fd}|S )Nc                 D    |  |       S j                   j                  S N)dbapi
BinaryNull)r    DBAPIBinaryr$   s    r   r!   z1_VARBINARY_mxodbc.bind_processor.<locals>.processf   s&     "5)) }}///r   )r6   Binary)r#   r$   r!   r8   s    ` @r   r%   z _VARBINARY_mxodbc.bind_processor`   s+    == mm**	0 r   N)r   r   r   r   r%   r   r   r   r2   r2   W   s    r   r2   c                       e Zd ZdZy)MSExecutionContext_mxodbcz
    The pyodbc execution context is useful for enabling
    SELECT SCOPE_IDENTITY in cases where OUTPUT clause
    does not work (tables with insert triggers).
    Nr   r   r   r   r;   r;   p   s    r   r;   c                        e Zd ZdZeZdZej                  e	ej                  eej                  eej                  eeeej$                  eiZd fd	Z xZS )MSDialect_mxodbcTc                 :    t        t        | 
  di | || _        y )Nr   )superr=   __init__description_encoding)r#   rA   params	__class__s      r   r@   zMSDialect_mxodbc.__init__   s    .88$8!r   r5   )r   r   r   supports_statement_cacher;   execution_ctx_cls_need_decimal_fixsqltypesNumericr   DateTimer   Dater   Timer*   r   r2   LargeBinarycolspecsr@   __classcell__)rC   s   @r   r=   r=   |   sg    
  $1  	+;~~$/H9 9r   r=   N)r   baser   r   r   r   r   pyodbcr   r	    r   rG   connectors.mxodbcr   r   r   r*   r2   r;   r=   r$   r   r   r   <module>rS      s{   'T      % - ! 0.) .W W 	 2 9 9	 94 r   