
    .th                     L    S SK r S SKrS SKrS SKrSSKJrJrJ	r	J
r
Jr  S rS rg)    N   )	db_dbnamedb_userdb_passworddb_hostdb_portc                 4   US:X  a%  [        U SSS9 nUR                  5       sSSS5        $ [        U S5       nS[        R                  " UR                  5       5      R	                  S5       3sSSS5        $ ! , (       d  f       g= f! , (       d  f       g= f)z7Read and convert image files to base64-encoded strings.svgrzutf-8)encodingNrbzdata:image/jpeg;base64,)openreadbase64	b64encodedecode)	file_path	file_typefiles      ./srv/www/htdocs/dashboard-gnss/utils/common.pyreplace_imager      sy    E)S73t99; 43 )T"d,V-=-=diik-J-Q-QRY-Z,[\ #" 43 #"s   A86B	8
B	
Bc                     [         R                  " [        [        [        [
        [        S9nUR                  5       nUR                  U 5        UR                  5       nUR                   Vs/ s H  oDS   PM	     nn[        R                  " X5S9nUU(       a  UR                  5         U(       a  UR                  5         $ $ s  snf ! [         R                   aR  n[        R                   " SU 35         S nAW(       a  UR                  5         W(       a  UR                  5         g g S nAff = f! W(       a  UR                  5         W(       a  UR                  5         f f = f)N)dbnameuserpasswordhostportr   )columnsz Error connecting to PostgreSQL: )psycopg2connectr   r   r   r   r   cursorexecutefetchalldescriptionpd	DataFramecloseErrorsterror)query
connectionr!   recordsdescr   dfes           r   	load_datar1      s   %% 

 ""$u//#'-'9'9:'9t7'9:\\'3
 LLN  ; >> 
3A378LLN  LLN s<   A+C -C;C C D-D(4D0 (D--D0 01E!)r   r   	streamlitr)   pandasr%   credentialsr   r   r   r   r   r   r1        r   <module>r7      s"        J J]r6   