
    h                        d dl mZ d dlZd dlZd dlZd dlm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Zej$                   G d d	             Zdd
ZddZddZy)    )annotationsN)perf_counter)current_app)g)has_app_contextc                 .    t        j                  dg       S )a  Get the list of recorded query information for the current session. Queries are
    recorded if the config :data:`.SQLALCHEMY_RECORD_QUERIES` is enabled.

    Each query info object has the following attributes:

    ``statement``
        The string of SQL generated by SQLAlchemy with parameter placeholders.
    ``parameters``
        The parameters sent with the SQL statement.
    ``start_time`` / ``end_time``
        Timing info about when the query started execution and when the results where
        returned. Accuracy and value depends on the operating system.
    ``duration``
        The time the query took in seconds.
    ``location``
        A string description of where in your application code the query was executed.
        This may not be possible to calculate, and the format is not stable.

    .. versionchanged:: 3.0
        Renamed from ``get_debug_queries``.

    .. versionchanged:: 3.0
        The info object is a dataclass instead of a tuple.

    .. versionchanged:: 3.0
        The info object attribute ``context`` is renamed to ``location``.

    .. versionchanged:: 3.0
        Not enabled automatically in debug or testing mode.
    _sqlalchemy_queries)r   get     HD:\EasyAligner\venv\Lib\site-packages\flask_sqlalchemy/record_queries.pyget_recorded_queriesr      s    > 55&++r   c                  V    e Zd ZU dZded<   ded<   ded<   ded<   d	ed
<   edd       Zy)
_QueryInfoa8  Information about an executed query. Returned by :func:`get_recorded_queries`.

    .. versionchanged:: 3.0
        Renamed from ``_DebugQueryTuple``.

    .. versionchanged:: 3.0
        Changed to a dataclass instead of a tuple.

    .. versionchanged:: 3.0
        ``context`` is renamed to ``location``.
    z
str | None	statementt.Any
parametersfloat
start_timeend_timestrlocationc                4    | j                   | j                  z
  S N)r   r   )selfs    r   durationz_QueryInfo.durationE   s    }}t..r   N)returnr   )__name__
__module____qualname____doc____annotations__propertyr   r   r   r   r   r   1   s7    
 OM/ /r   r   c                x    t        j                  | dt        d       t        j                  | dt        d       y )Nbefore_cursor_executeT)namedafter_cursor_execute)sa_eventlisten_record_start_record_end)engines    r   _listenr-   J   s(    OOF3]$OOOF2KtLr   c                8    t               sy t               | _        y r   )r   r   _fsa_start_time)contextkwargss     r   r*   r*   O   s    *nGr   c           	     T   t               sy dt        vrg t        _        t        j                  j                  d      d   }| d}t        j                         }|rx|j                  j                  d      }|rL||k(  s|j                  |      r6|j                  }|j                   d|j                   d|j                   d}n|j                  }|rxd}t        j                  j!                  t#        | j$                  | j&                  | j(                  t+               |	             y )
Nr	   .r   r   :z ()z	<unknown>)r   r   r   r   r   )r   r   r	   r   import_name	partitioninspectcurrentframe	f_globalsr
   
startswithf_codeco_filenamef_linenoco_namef_backappendr   r   r   r/   r   )r0   r1   
import_top
import_dotframenamecoder   s           r   r+   r+   V   s   A% "((2237:J<q!J  "E
"":.TZ'4??:+F<<D**+1U^^,<Bt||nANH    ''))..!^	
r   )r   zlist[_QueryInfo])r,   zsa.engine.Enginer   None)r0   zsa.engine.ExecutionContextr1   r   r   rG   )
__future__r   dataclassesr8   typingttimer   
sqlalchemysasqlalchemy.eventeventr(   flaskr   r   r   r   	dataclassr   r-   r*   r+   r   r   r   <module>rS      sX    "      #   !,D / / /0M
-r   