
    yIf                        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dS )    )annotationsN)perf_counter)current_app)g)has_app_contextreturnlist[_QueryInfo]c                 ,    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     S/var/www/piapp/venv/lib/python3.11/site-packages/flask_sqlalchemy/record_queries.pyget_recorded_queriesr      s    > 5&+++r   c                  ^    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dS )
_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locationr   c                     | j         | j        z
  S N)r   r   )selfs    r   durationz_QueryInfo.durationE   s    }t..r   N)r   r   )__name__
__module____qualname____doc____annotations__propertyr   r   r   r   r   r   1   sv         
 
 OOOMMM/ / / X/ / /r   r   enginesa.engine.EngineNonec                z    t          j        | dt          d           t          j        | dt          d           d S )Nbefore_cursor_executeT)namedafter_cursor_execute)sa_eventlisten_record_start_record_end)r%   s    r   _listenr0   J   s<    OF3]$OOOOOF2KtLLLLLLr   contextsa.engine.ExecutionContextkwargsr   c                L    t                      sd S t                      | _        d S r   )r   r   _fsa_start_time)r1   r3   s     r   r.   r.   O   s'     *nnGr   c           	     .   t                      sd S dt          vrg t          _        t          j                            d          d         }| d}t          j                    }|rb|j        	                    d          }|r=||k    s|
                    |          r"|j        }|j         d|j         d|j         d}n|j        }|bd}t          j                            t#          | j        | j        | j        t+                      |	                     d S )
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   r5   r   )r1   r3   
import_top
import_dotframenamecoder   s           r   r/   r/   V   s9    A%% "(22377:J!!!J ""E
 
"":.. 	TZ''4??:+F+F'<D*NNU^NNt|NNNH  
   ').!^^	
 	
 	
    r   )r   r	   )r%   r&   r   r'   )r1   r2   r3   r   r   r'   )
__future__r   dataclassesr<   typingttimer   
sqlalchemysasqlalchemy.eventeventr,   flaskr   r   r   r   	dataclassr   r0   r.   r/   r   r   r   <module>rV      s5   " " " " " "                    # # # # # #             ! ! ! ! ! !, , , ,D / / / / / / / /0M M M M
- - - -     r   