o
    "4g                     @  s^   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 G d	d
 d
ZdS )z>
Objects to return information about a PostgreSQL connection.
    )annotations)Path)tzinfo   )pq)
get_tzinfo)make_conninfoc                   @  s*  e Zd ZdZdZd;ddZed<d	d
Zed<ddZed<ddZed=ddZ	ed<ddZ
ed<ddZed<ddZed<ddZd>ddZed<ddZed?d d!Zed@d#d$ZedAd&d'ZdBd*d+Zed=d,d-Zed=d.d/Zed<d0d1ZedCd3d4Zed<d5d6ZdDd8d9Zd:S )EConnectionInfoz1Allow access to information about the connection.psycopgpgconnpq.abc.PGconnc                 C  s
   || _ d S N)r   )selfr    r   a/var/www/html/authentication-server/venv/lib/python3.10/site-packages/psycopg/_connection_info.py__init__   s   
zConnectionInfo.__init__returnstrc                 C  s   dS )z7A string representing the database vendor connected to.
PostgreSQLr   r   r   r   r   vendor   s   zConnectionInfo.vendorc                 C  
   |  dS )zBThe server host name of the active connection. See :pq:`PQhost()`.host_get_pgconn_attrr   r   r   r   r         
zConnectionInfo.hostc                 C  r   )z@The server IP address of the connection. See :pq:`PQhostaddr()`.hostaddrr   r   r   r   r   r   #   r   zConnectionInfo.hostaddrintc                 C  s   t | dS )z6The port of the active connection. See :pq:`PQport()`.port)r   r   r   r   r   r   r   (      zConnectionInfo.portc                 C  r   )z6The database name of the connection. See :pq:`PQdb()`.dbr   r   r   r   r   dbname-   r   zConnectionInfo.dbnamec                 C  r   )z4The user name of the connection. See :pq:`PQuser()`.userr   r   r   r   r   r"   2   r   zConnectionInfo.userc                 C  r   )z3The password of the connection. See :pq:`PQpass()`.passwordr   r   r   r   r   r#   7   r   zConnectionInfo.passwordc                 C  r   )zi
        The command-line options passed in the connection request.
        See :pq:`PQoptions`.
        optionsr   r   r   r   r   r$   <      
zConnectionInfo.optionsdict[str, str]c                   sV   | j dd tj D   dd tt d   d<  fd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                 S  s    i | ]}|j d ur|j|j qS r   )compiledkeyword.0ir   r   r   
<dictcomp>O   s
    
z1ConnectionInfo.get_parameters.<locals>.<dictcomp>s   channel_bindings   preferz.pgpasss   passfilec                   sH   i | ] }|j d ur"|jdkr"|j  |jkr|j|j qS )Ns   password)valr(   getdecoder)   defaultspyencr   r   r,   X   s    

)encodingr   Conninfoget_defaults
setdefaultr   r   homeencoder   infor   r   r0   r   get_parametersD   s   zConnectionInfo.get_parametersc                 C  s   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).
        Nr   )r   r:   r   r   r   r   dsn`   s   
zConnectionInfo.dsnpq.ConnStatusc                 C     t | jjS )z3The status of the connection. See :pq:`PQstatus()`.)r   
ConnStatusr   statusr   r   r   r   r?   l   r   zConnectionInfo.statuspq.TransactionStatusc                 C  r=   )zl
        The current in-transaction status of the session.
        See :pq:`PQtransactionStatus()`.
        )r   TransactionStatusr   transaction_statusr   r   r   r   rB   q      z!ConnectionInfo.transaction_statuspq.PipelineStatusc                 C  r=   )zb
        The current pipeline status of the client.
        See :pq:`PQpipelineStatus()`.
        )r   PipelineStatusr   pipeline_statusr   r   r   r   rF   y   rC   zConnectionInfo.pipeline_status
param_name
str | Nonec                 C  s,   | j || j}|dur|| jS dS )zs
        Return a parameter setting of the connection.

        Return `None` is the parameter is unknown.
        N)r   parameter_statusr8   r3   r/   )r   rG   resr   r   r   rI      s   zConnectionInfo.parameter_statusc                 C     | j jS )zZ
        An integer representing the server version. See :pq:`PQserverVersion()`.
        )r   server_versionr   r   r   r   rL      s   zConnectionInfo.server_versionc                 C  rK   )zy
        The process ID (PID) of the backend process handling this connection.
        See :pq:`PQbackendPID()`.
        )r   backend_pidr   r   r   r   rM      s   zConnectionInfo.backend_pidc                 C  r   )z
        The error message most recently generated by an operation on the connection.
        See :pq:`PQerrorMessage()`.
        error_messager   r   r   r   r   rN      r%   zConnectionInfo.error_messager   c                 C  s
   t | jS )z6The Python timezone info of the connection's timezone.)r   r   r   r   r   r   timezone   r   zConnectionInfo.timezonec                 C  rK   )z:The Python codec name of the connection's client encoding.)r   	_encodingr   r   r   r   r3      s   zConnectionInfo.encodingnamec                 C  s   t | j|}|| jS r   )getattrr   r/   r3   )r   rQ   valuer   r   r   r      s   zConnectionInfo._get_pgconn_attrN)r   r   )r   r   )r   r   )r   r&   )r   r<   )r   r@   )r   rD   )rG   r   r   rH   )r   r   )rQ   r   r   r   )__name__
__module____qualname____doc__r   propertyr   r   r   r   r!   r"   r#   r$   r:   r;   r?   rB   rF   rI   rL   rM   rN   rO   r3   r   r   r   r   r   r	      sR    


	r	   N)rW   
__future__r   pathlibr   datetimer    r   _tzr   conninfor   r	   r   r   r   r   <module>   s    