Ë
    aQbjž  ã                   óX   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ededee   fd„«       Z	y	)
z×Atomic transaction context manager utilities for MySQL Connector/Python.

Provides context manager atomic_transaction() that ensures commit on success
and rollback on error without obscuring the original exception.
é    )Úcontextmanager)ÚIterator)ÚMySQLConnectionAbstract)ÚMySQLCursorAbstractÚconnÚreturnc              #   ó˜  K  — | j                   }| j                  «       }d}	 |rd| _         |–— | j                  «        	 || _         	 |j                  «        y# t        $ r$ d}	 | j	                  «        ‚ # t        $ r Y ‚ w xY ww xY w# t        $ r |s‚ Y yw xY w# || _         	 |j                  «        w # t        $ r |s‚ Y w w xY wxY w­w)a   
    Context manager that wraps a MySQL database cursor and ensures transaction
    rollback in case of exception.

    NOTE: DDL statements such as CREATE TABLE cause implicit commits. These cannot
    be managed by a cursor object. Changes made at or before a DDL statement will
    be committed and not rolled back. Callers are responsible for any cleanup of
    this type.

    This class acts as a robust, PEP 343-compliant context manager for handling
    database cursor operations on a MySQL connection. It ensures that all operations
    executed within the context block are part of the same transaction, and
    automatically calls `connection.rollback()` if an exception occurs, helping
    to maintain database integrity. On normal completion (no exception), it simply
    closes the cursor after use. Exceptions are always propagated to the caller.

    Args:
        conn: A MySQLConnectionAbstract instance.
    FTN)Ú
autocommitÚcursorÚcommitÚ	ExceptionÚrollbackÚclose)r   Úold_autocommitr   Úexception_raiseds       úO/var/www/html/venv/lib/python3.12/site-packages/mysql/ai/utils/atomic_cursor.pyÚatomic_transactionr   *   sä   è ø€ ð. —_‘_€NØ�[‰[‹]€FàÐðÙØ#ˆDŒOàŠà�‰�ð )ˆŒð	Ø�L‰L�Nøô ò 	ØÐð	Ø�M‰MŒOð 	øô ò 	àð 	ð	úð		ûô ò 	á#Øñ $ð	ûð	 )ˆŒð	Ø�L‰L�NøÜò 	á#Øñ $ð	ÿs”   ‚C
¢A Á C
ÁB	 ÁC
ÁBÁ%A6Á5BÁ6	BÁ?BÂBÂBÂB Â	BÂC
ÂBÂC
ÂCÂ$B5Â4CÂ5CÃCÃCÃCÃC
N)
Ú__doc__Ú
contextlibr   Útypingr   Úmysql.connector.abstractsr   Úmysql.connector.cursorr   r   © ó    r   ú<module>r      sB   ðñ:õ &Ý å =Ý 6ð ð3Ø
!ð3àÐ!Ñ"ò3ó ñ3r   