
    [h!                         d Z ddl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Z G d dej        ej                           Z G d de          Z G d de          Z G d de          ZeZdS )a  

.. dialect:: mysql+mariadbconnector
    :name: MariaDB Connector/Python
    :dbapi: mariadb
    :connectstring: mariadb+mariadbconnector://<user>:<password>@<host>[:<port>]/<dbname>
    :url: https://pypi.org/project/mariadb/

Driver Status
-------------

MariaDB Connector/Python enables Python programs to access MariaDB and MySQL
databases using an API which is compliant with the Python DB API 2.0 (PEP-249).
It is written in C and uses MariaDB Connector/C client library for client server
communication.

Note that the default driver for a ``mariadb://`` connection URI continues to
be ``mysqldb``. ``mariadb+mariadbconnector://`` is required to use this driver.

.. mariadb: https://github.com/mariadb-corporation/mariadb-connector-python

    N)UUID   )MySQLCompiler)MySQLDialect)MySQLExecutionContext   )sql)util)sqltypes)r   r   r   c                       e Zd Zd ZdS )_MariaDBUUIDc                 $    | j         rd }|S d }|S )Nc                 r    | 4t          | d          r|                     d          } t          |           } | S Ndecodeascii)hasattrr   _python_UUIDvalues    y/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/dialects/mysql/mariadbconnector.pyprocessz._MariaDBUUID.result_processor.<locals>.process5   s=    $uh// 6 %W 5 5(//E    c                     | At          | d          r|                     d          } t          t          |                     } | S r   )r   r   strr   r   s    r   r   z._MariaDBUUID.result_processor.<locals>.process?   sE    $uh// 6 %W 5 5U 3 344Er   )as_uuid)selfdialectcoltyper   s       r   result_processorz_MariaDBUUID.result_processor2   s8    < 	   N   Nr   N)__name__
__module____qualname__r     r   r   r   r   .   s#            r   r   c                   4     e Zd ZdZd Zd Z fdZd Z xZS )&MySQLExecutionContext_mariadbconnectorNc                 8    | j                             d          S )NFbuffered_dbapi_connectioncursorr   s    r   create_server_side_cursorz@MySQLExecutionContext_mariadbconnector.create_server_side_cursorL   s    %,,e,<<<r   c                 8    | j                             d          S )NTr(   r*   r-   s    r   create_default_cursorz<MySQLExecutionContext_mariadbconnector.create_default_cursorO   s    %,,d,;;;r   c                     t                                                       | j        j        | _        | j        r| j        j        r| j        j        | _	        d S d S d S N)
super	post_execr,   rowcount	_rowcountisinsertcompiledpostfetch_lastrowid	lastrowid
_lastrowid)r   	__class__s    r   r4   z0MySQLExecutionContext_mariadbconnector.post_execR   s_    -= 	4T]> 	4"k3DOOO	4 	4 	4 	4r   c                     | j         S r2   )r;   r-   s    r   get_lastrowidz4MySQLExecutionContext_mariadbconnector.get_lastrowidZ   s
    r   )	r!   r"   r#   r;   r.   r0   r4   r>   __classcell__r<   s   @r   r&   r&   I   sj        J= = =< < <4 4 4 4 4      r   r&   c                       e Zd ZdS )MySQLCompiler_mariadbconnectorN)r!   r"   r#   r$   r   r   rB   rB   ^   s        Dr   rB   c                   
    e Zd ZdZdZdZdZdZdZdZ	dZ
dZeZeZdZ ej        ej        ej        ei          Zej        d             Z fdZed             Z fdZd	 Zd
 Zd Z d Z! fdZ"d Z#d Z$	 ddZ%	 ddZ& xZ'S )MySQLDialect_mariadbconnectormariadbconnectorTutf8mb4qmarkc                     | j         rKt          | j         d          r6t          d t          j        d| j         j                  D                       S dS )N__version__c                 ,    g | ]}t          |          S r$   )int.0xs     r   
<listcomp>z@MySQLDialect_mariadbconnector._dbapi_version.<locals>.<listcomp>   s.        FF  r   z(\d+)(?:[-\.]?|$))c   rP   rP   )dbapir   tuplerefindallrI   r-   s    r   _dbapi_versionz,MySQLDialect_mariadbconnector._dbapi_version   sj    : 
	 '$*m<< 
	  Z,dj.D       <r   c                      t                      j        di | d| _        | j        D| j        t
          k     r6t          dd                    d t
          D                       z            d S d S )NrG   z?The minimum required version for MariaDB Connector/Python is %s.c              3   4   K   | ]}t          |          V  d S r2   )r   rL   s     r   	<genexpr>z9MySQLDialect_mariadbconnector.__init__.<locals>.<genexpr>   s(      KK!s1vvKKKKKKr   r$   )r3   __init__
paramstylerQ   rU   mariadb_cpy_minimum_versionNotImplementedErrorjoin)r   kwargsr<   s     r   rZ   z&MySQLDialect_mariadbconnector.__init__   s    ""6"""!:!"%@@@)-hhKK/JKKKKKL   "!@@r   c                      t          d          S )Nmariadb)
__import__)clss    r   import_dbapiz*MySQLDialect_mariadbconnector.import_dbapi   s    )$$$r   c                     t                                          |||          rdS t          || j        j                  r)t          |                                          }d|v pd|v S dS )NTznot connectedzisn't validF)r3   is_disconnect
isinstancerQ   Errorr   lower)r   e
connectionr,   str_er<   s        r   rf   z+MySQLDialect_mariadbconnector.is_disconnect   sj    77  J77 	44:+,, 	FFLLNNE"e+E}/EE5r   c                    |                                 }|                    |j                   g d}g d}|D ]}t          j        ||t
                     |D ]}t          j        ||t                     |                    dd          }| j        U	 t          | j        j
        dz             j        j        }||j        z  }n# t          t          f$ r
 d| _        Y nw xY w||d<   g |gS )N)connect_timeoutread_timeoutwrite_timeoutclient_flagport	pool_size)local_infilessl_verify_certsslpool_reset_connectioncompressrq   r   z.constants.CLIENTF)translate_connect_argsupdatequeryr
   coerce_kw_typerK   boolgetrQ   rb   r!   	constantsCLIENT
FOUND_ROWSAttributeErrorImportErrorsupports_sane_rowcount)r   urlopts
int_paramsbool_paramskeyrq   CLIENT_FLAGSs           r   create_connect_argsz1MySQLDialect_mariadbconnector.create_connect_args   s3   ))++CI
 
 


 
 
  	0 	0Cc3//// 	1 	1Cc40000 hh}a00:!4)J'*==   F  |66"K0 4 4 4.3+++4"-DDzs   0C C! C!c                 *    	 |j         }n	#  d}Y nxY w|S )N)errno)r   	exceptionrcs      r   _extract_error_codez1MySQLDialect_mariadbconnector._extract_error_code   s'    	BB	BBB	s   
 c                     dS )NrF   r$   )r   rk   s     r   _detect_charsetz-MySQLDialect_mariadbconnector._detect_charset   s    yr   c                     dS )N)SERIALIZABLEzREAD UNCOMMITTEDzREAD COMMITTEDzREPEATABLE READ
AUTOCOMMITr$   )r   dbapi_connections     r   get_isolation_level_valuesz8MySQLDialect_mariadbconnector.get_isolation_level_values   s    
 
r   c                 x    |dk    r	d|_         d S d|_         t                                          ||           d S )Nr   TF)
autocommitr3   set_isolation_level)r   rk   levelr<   s      r   r   z1MySQLDialect_mariadbconnector.set_isolation_level   sD    L  $(J!!!$)J!GG''
E:::::r   c           	          |                     t          j        d                              t          j        d|d                               d S )NzXA BEGIN :xidxidTliteral_executeexecuter	   text
bindparams	bindparamr   rk   r   s      r   do_begin_twophasez/MySQLDialect_mariadbconnector.do_begin_twophase   sU    H_%%00eS$??? 	
 	
 	
 	
 	
r   c           	      B   |                     t          j        d                              t          j        d|d                               |                     t          j        d                              t          j        d|d                               d S )NXA END :xidr   Tr   zXA PREPARE :xidr   r   s      r   do_prepare_twophasez1MySQLDialect_mariadbconnector.do_prepare_twophase   s    H]##..eS$??? 	
 	
 	

 	H&''22eS$??? 	
 	
 	
 	
 	
r   Fc           	      F   |sO|                     t          j        d                              t          j        d|d                               |                     t          j        d                              t          j        d|d                               d S )Nr   r   Tr   zXA ROLLBACK :xidr   r   rk   r   is_preparedrecovers        r   do_rollback_twophasez2MySQLDialect_mariadbconnector.do_rollback_twophase   s      	''22M%dCCC   
 	H'((33eS$??? 	
 	
 	
 	
 	
r   c           	          |s|                      ||           |                    t          j        d                              t          j        d|d                               d S )NzXA COMMIT :xidr   Tr   )r   r   r	   r   r   r   r   s        r   do_commit_twophasez0MySQLDialect_mariadbconnector.do_commit_twophase	  sv      	6$$Z555H%&&11eS$??? 	
 	
 	
 	
 	
r   )TF)(r!   r"   r#   driversupports_statement_cachesupports_unicode_statementsencodingconvert_unicoder   supports_sane_multi_rowcountsupports_native_decimaldefault_paramstyler&   execution_ctx_clsrB   statement_compilersupports_server_side_cursorsr
   update_copyr   colspecsr   Uuidr   memoized_propertyrU   rZ   classmethodrd   rf   r   r   r   r   r   r   r   r   r   r?   r@   s   @r   rD   rD   b   s       F# #'HO!#' " >7#' t|< H 
     	 	 	 	 	 % % [%    % % %N    
 
 
; ; ; ; ;
 
 


 

 

 :?
 
 
 
  :?	
 	
 	
 	
 	
 	
 	
 	
r   rD   )__doc__rS   uuidr   r   baser   r   r    r	   r
   r   r\   _UUID_RETURNr   r&   rB   rD   r   r$   r   r   <module>r      sg   , 
			 % % % % % %             ' ' ' ' ' '                   (     8=!67   6    -B   *	 	 	 	 	] 	 	 	p
 p
 p
 p
 p
L p
 p
 p
f (r   