
    *Jf                    x    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dS )z>
Objects to return information about a PostgreSQL connection.
    )annotations)Path)tzinfo   )pq)
get_tzinfo)pgconn_encoding)make_conninfoc                     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d%S )0ConnectionInfoz1Allow access to information about the connection.psycopgpgconnpq.abc.PGconnc                    || _         d S N)r   )selfr   s     [/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/psycopg/_connection_info.py__init__zConnectionInfo.__init__   s        returnstrc                    dS )z7A string representing the database vendor connected to.
PostgreSQL r   s    r   vendorzConnectionInfo.vendor   s	     |r   c                ,    |                      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                ,    |                      d          S )z@The server IP address of the connection. See :pq:`PQhostaddr()`.hostaddrr   r   s    r   r#   zConnectionInfo.hostaddr$        $$Z000r   intc                F    t          |                     d                    S )z6The port of the active connection. See :pq:`PQport()`.port)r%   r    r   s    r   r'   zConnectionInfo.port)   s      4((00111r   c                ,    |                      d          S )z6The database name of the connection. See :pq:`PQdb()`.dbr   r   s    r   dbnamezConnectionInfo.dbname.   s     $$T***r   c                ,    |                      d          S )z4The user name of the connection. See :pq:`PQuser()`.userr   r   s    r   r,   zConnectionInfo.user3   r!   r   c                ,    |                      d          S )z3The password of the connection. See :pq:`PQpass()`.passwordr   r   s    r   r.   zConnectionInfo.password8   r$   r   c                ,    |                      d          S )zi
        The command-line options passed in the connection request.
        See :pq:`PQoptions`.
        optionsr   r   s    r   r0   zConnectionInfo.options=   s     $$Y///r   dict[str, str]c                2   | j         d t          j                                        D                                 dd           t          t          j                    dz                                            d<   fd| j	        j
        D             S )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).
        c                6    i | ]}|j         	|j        |j         S r   )compiledkeyword).0is     r   
<dictcomp>z1ConnectionInfo.get_parameters.<locals>.<dictcomp>P   s0     
 
 
z% Iqz%%%r   s   channel_bindings   preferz.pgpasss   passfilec                    i | ]j}|j         a|j        dk    rV|j                             |j                  k    7|j                                      |j                                       kS )Ns   password)valr5   getdecode)r6   r7   defaultspyencs     r   r8   z1ConnectionInfo.get_parameters.<locals>.<dictcomp>Y   su     
 
 
u 	[((ai0000	 IU##QU\\%%8%8 100r   )encodingr   Conninfoget_defaults
setdefaultr   r   homeencoder   info)r   r=   r>   s    @@r   get_parameterszConnectionInfo.get_parametersE   s     
 
[--//
 
 
 	.	::: #DIKK)$; < < C C E E
 
 
 
 
[%
 
 
 	
r   c                >    t          di |                                 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
   rF   r   s    r   dsnzConnectionInfo.dsna   s$     55t2244555r   pq.ConnStatusc                >    t          j        | j        j                  S )z3The status of the connection. See :pq:`PQstatus()`.)r   
ConnStatusr   statusr   s    r   rL   zConnectionInfo.statusm   s     }T[/000r   pq.TransactionStatusc                >    t          j        | j        j                  S )zl
        The current in-transaction status of the session.
        See :pq:`PQtransactionStatus()`.
        )r   TransactionStatusr   transaction_statusr   s    r   rP   z!ConnectionInfo.transaction_statusr   s     #DK$BCCCr   pq.PipelineStatusc                >    t          j        | j        j                  S )zb
        The current pipeline status of the client.
        See :pq:`PQpipelineStatus()`.
        )r   PipelineStatusr   pipeline_statusr   s    r   rT   zConnectionInfo.pipeline_statusz   s      !<===r   
param_name
str | Nonec                    | j                             |                    | j                            }||                    | j                  ndS )zs
        Return a parameter setting of the connection.

        Return `None` is the parameter is unknown.
        N)r   parameter_statusrD   r?   r<   )r   rU   ress      r   rX   zConnectionInfo.parameter_status   sF     k**:+<+<T]+K+KLL,/Oszz$-(((Er   c                    | j         j        S )zZ
        An integer representing the server version. See :pq:`PQserverVersion()`.
        )r   server_versionr   s    r   r[   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   r]   zConnectionInfo.backend_pid   s     {&&r   c                ,    |                      d          S )z
        The error message most recently generated by an operation on the connection.
        See :pq:`PQerrorMessage()`.
        error_messager   r   s    r   r_   zConnectionInfo.error_message   s     $$_555r   r   c                *    t          | j                  S )z6The Python timezone info of the connection's timezone.)r   r   r   s    r   timezonezConnectionInfo.timezone   s     $+&&&r   c                *    t          | j                  S )z:The Python codec name of the connection's client encoding.)r	   r   r   s    r   r?   zConnectionInfo.encoding   s     t{+++r   namec                `    t          | j        |          }|                    | j                  S r   )getattrr   r<   r?   )r   rc   values      r   r    zConnectionInfo._get_pgconn_attr   s'    t{D11||DM***r   N)r   r   )r   r   )r   r%   )r   r1   )r   rI   )r   rM   )r   rQ   )rU   r   r   rV   )r   r   )rc   r   r   r   )__name__
__module____qualname____doc__r   propertyr   r   r#   r'   r*   r,   r.   r0   rF   rH   rL   rP   rT   rX   r[   r]   r_   ra   r?   r    r   r   r   r   r      s       ;;J       X - - - X- 1 1 1 X1 2 2 2 X2 + + + X+ - - - X- 1 1 1 X1 0 0 0 X0
 
 
 
8 	6 	6 	6 X	6 1 1 1 X1 D D D XD > > > X>F F F F * * * X* ' ' ' X' 6 6 6 X6 ' ' ' X' , , , X,+ + + + + +r   r   N)rj   
__future__r   pathlibr   datetimer    r   _tzr   
_encodingsr	   conninfor
   r   r   r   r   <module>rs      s     # " " " " "                         ' ' ' ' ' ' # # # # # #\+ \+ \+ \+ \+ \+ \+ \+ \+ \+r   