
    i,                    p    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  G d
 d      Zy)z>
Objects to return information about a PostgreSQL connection.
    )annotations)Path)tzinfo   )errors)pq)
get_tzinfo)make_conninfoc                  f   e Zd ZdZdZddZedd       Zedd       Zedd       Zedd       Z	edd       Z
edd	       Zedd
       Zedd       ZddZedd       Zedd       Zedd       Zedd       Zd dZedd       Zedd       Zedd       Zed!d       Zedd       Zd"dZy)#ConnectionInfoz1Allow access to information about the connection.psycopgc                    || _         y N)pgconn)selfr   s     x/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/venv/lib/python3.12/site-packages/psycopg/_connection_info.py__init__zConnectionInfo.__init__   s	        c                     y)z7A string representing the database vendor connected to.
PostgreSQL r   s    r   vendorzConnectionInfo.vendor   s     r   c                $    | j                  d      S )zBThe server host name of the active connection. See :pq:`PQhost()`.host_get_pgconn_attrr   s    r   r   zConnectionInfo.host        $$V,,r   c                $    | j                  d      S )z@The server IP address of the connection. See :pq:`PQhostaddr()`.hostaddrr   r   s    r   r    zConnectionInfo.hostaddr$        $$Z00r   c                    | j                  d      x}rt        |      S t        j                  j	                         x}rt        |      S t        j                  d      )z6The port of the active connection. See :pq:`PQport()`.portz!couldn't find the connection port)r   intr   miscget_compiled_porteInternalError)r   r#   s     r   r#   zConnectionInfo.port)   sX     ((0040t9
 WW..00T0t9ooABBr   c                $    | j                  d      S )z6The database name of the connection. See :pq:`PQdb()`.dbr   r   s    r   dbnamezConnectionInfo.dbname7   s     $$T**r   c                $    | j                  d      S )z4The user name of the connection. See :pq:`PQuser()`.userr   r   s    r   r-   zConnectionInfo.user<   r   r   c                $    | j                  d      S )z3The password of the connection. See :pq:`PQpass()`.passwordr   r   s    r   r/   zConnectionInfo.passwordA   r!   r   c                $    | j                  d      S )zi
        The command-line options passed in the connection request.
        See :pq:`PQoptions`.
        optionsr   r   s    r   r1   zConnectionInfo.optionsF   s     $$Y//r   c                   | j                   }t        j                  j                         D ci c]%  }|j                  |j
                  |j                  ' }}|j                  dd       t        t        j                         dz        j                         |d<   | j                  j                  D ci c]z  }|j                  l|j
                  dk7  r]|j                  |j                  |j
                        k7  r5|j
                  j                  |      |j                  j                  |      | c}S c c}w c c}w )a\  Return the connection parameters values.

        Return all the parameters set to a non-default value, which might come
        either from the connection string and parameters passed to
        `~Connection.connect()` or from environment variables. The password
        is never returned (you can read it using the `password` attribute).
        s   channel_bindings   preferz.pgpasss   passfiles   password)encodingr   Conninfoget_defaultscompiledkeyword
setdefaultstrr   homeencoder   infovalgetdecode)r   pyencidefaultss       r   get_parameterszConnectionInfo.get_parametersN   s    
 [[--/
zz% IIqzz!
 
 	.	: #DIIK)$; < C C E [[%%
uu 		[(aii00	 IIU#QUU\\%%88
 	


s   *D64A?D;c                4    t        di | j                         S )a  Return the connection string to connect to the database.

        The string contains all the parameters set to a non-default value,
        which might come either from the connection string and parameters
        passed to `~Connection.connect()` or from environment variables. The
        password is never returned (you can read it using the `password`
        attribute).
        r   )r
   rC   r   s    r   dsnzConnectionInfo.dsnj   s     5t22455r   c                T    t        j                  | j                  j                        S )z3The status of the connection. See :pq:`PQstatus()`.)r   
ConnStatusr   statusr   s    r   rH   zConnectionInfo.statusv   s     }}T[[//00r   c                T    t        j                  | j                  j                        S )zl
        The current in-transaction status of the session.
        See :pq:`PQtransactionStatus()`.
        )r   TransactionStatusr   transaction_statusr   s    r   rK   z!ConnectionInfo.transaction_status{   s     ##DKK$B$BCCr   c                T    t        j                  | j                  j                        S )zb
        The current pipeline status of the client.
        See :pq:`PQpipelineStatus()`.
        )r   PipelineStatusr   pipeline_statusr   s    r   rN   zConnectionInfo.pipeline_status   s       !<!<==r   c                    | j                   j                  |j                  | j                              }||j	                  | j                        S dS )zs
        Return a parameter setting of the connection.

        Return `None` is the parameter is unknown.
        N)r   parameter_statusr;   r3   r?   )r   
param_nameress      r   rP   zConnectionInfo.parameter_status   sC     kk**:+<+<T]]+KL,/Oszz$--(EEr   c                .    | j                   j                  S )zZ
        An integer representing the server version. See :pq:`PQserverVersion()`.
        )r   server_versionr   s    r   rT   zConnectionInfo.server_version   s    
 {{)))r   c                .    | j                   j                  S )zy
        The process ID (PID) of the backend process handling this connection.
        See :pq:`PQbackendPID()`.
        )r   backend_pidr   s    r   rV   zConnectionInfo.backend_pid   s     {{&&&r   c                $    | j                  d      S )z
        The error message most recently generated by an operation on the connection.
        See :pq:`PQerrorMessage()`.
        error_messager   r   s    r   rX   zConnectionInfo.error_message   s     $$_55r   c                ,    t        | j                        S )z6The Python timezone info of the connection's timezone.)r	   r   r   s    r   timezonezConnectionInfo.timezone   s     $++&&r   c                .    | j                   j                  S )z:The Python codec name of the connection's client encoding.)r   	_encodingr   s    r   r3   zConnectionInfo.encoding   s     {{$$$r   c                d    t        | j                  |      }|j                  | j                        S r   )getattrr   r?   r3   )r   namevalues      r   r   zConnectionInfo._get_pgconn_attr   s%    t{{D1||DMM**r   N)r   zpq.abc.PGconn)returnr9   )ra   r$   )ra   zdict[str, str])ra   zpq.ConnStatus)ra   zpq.TransactionStatus)ra   zpq.PipelineStatus)rQ   r9   ra   z
str | None)ra   r   )r_   r9   ra   r9   )__name__
__module____qualname____doc__r   propertyr   r   r    r#   r+   r-   r/   r1   rC   rE   rH   rK   rN   rP   rT   rV   rX   rZ   r3   r   r   r   r   r   r      sw   ;J   - - 1 1 C C + + - - 1 1 0 0
8 	6 	6 1 1 D D > >F * * ' ' 6 6 ' ' % %+r   r   N)re   
__future__r   pathlibr   datetimer    r   r'   r   _tzr	   conninfor
   r   r   r   r   <module>rm      s-    #      #e+ e+r   