<jupyter_start><jupyter_text>Postgres / PostGIS connectionWithin the Kubernetes cluster the service "postgres" is the gatway to connect to the K8S cluster.As host in the connect details 'postgres' can be used. Username for the database is also postgres and the password is equal to the password defined in the credentials. This password is stored as a Kubernetes secret and mapped to an evironment variable in the pod.<jupyter_code>import psycopg2
import os
host = 'postgres'
database = 'postgres'
user = 'postgres'
password = os.environ['<PASSWORD>']
connection_string = f'host={host} dbname={database} user={user} password={password}'
with psycopg2.connect(connection_string) as conn:
    with conn.cursor() as curs:
        curs.execute('SELECT version();')
        result = curs.fetchone();
        print(result)<jupyter_output>('PostgreSQL 13.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit',)
{'fraction_non_alphanumeric': 0.09523809523809523, 'fraction_numerical': 0.0380952380952381, 'mean_word_length': 5.025477707006369, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '357393', 'license': 'Apache-2.0', 'n_tokens_mistral': 313, 'n_tokens_neox': 283, 'n_words': 103, 'path': 'data/jupyter/Samples/200_TestPostGisConnection.ipynb', 'repo_name': 'cobra79/GeoGeekSuite', 'size': '945'}