diff --git a/geoBoundaryBuilder/A_sourceIngest.py b/geoBoundaryBuilder/A_sourceIngest.py deleted file mode 100644 index e69de29..0000000 diff --git a/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile b/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile index e719b6e..84d5d49 100644 --- a/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile +++ b/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile @@ -16,6 +16,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ make \ git \ git-lfs \ + openssh-client \ gdal-bin \ libgdal-dev \ libgeos-dev \ @@ -48,5 +49,6 @@ RUN pip install geopandas==0.13.2 kubernetes==31.0.0 # Install additional Python packages RUN pip install jsonschema==4.19.0 zipfile36==0.1.3 -# Set up git-lfs -RUN git lfs install +# Set up git-lfs and SSH +RUN git lfs install --system && \ + ssh-keygen -A # Ensures SSH host keys are generated if needed diff --git a/geoBoundaryBuilder/scripts/A_sourceIngest.py b/geoBoundaryBuilder/scripts/A_sourceIngest.py new file mode 100644 index 0000000..49282f4 --- /dev/null +++ b/geoBoundaryBuilder/scripts/A_sourceIngest.py @@ -0,0 +1,49 @@ +import psycopg2 +from psycopg2 import sql + +# Connection parameters +DB_HOST = "geoboundaries-postgres-service" # Service name resolves to the ClusterIP +DB_PORT = "5432" # Default PostgreSQL port +DB_NAME = "geoboundaries" # Database name +DB_USER = "geoboundaries" # Username +DB_PASSWORD = "" # Empty password since host auth is trust + +def test_postgis_connection(): + try: + # Establish connection + print("Connecting to the PostGIS database...") + conn = psycopg2.connect( + dbname=DB_NAME, + user=DB_USER, + password=DB_PASSWORD, + host=DB_HOST, + port=DB_PORT + ) + print("Connection successful!") + + # Create a cursor object + cursor = conn.cursor() + + # Test if PostGIS extension is enabled + cursor.execute("SELECT PostGIS_Version();") + postgis_version = cursor.fetchone() + if postgis_version: + print(f"PostGIS Version: {postgis_version[0]}") + else: + print("Failed to fetch PostGIS version. Is PostGIS enabled?") + + # Test a basic query + cursor.execute("SELECT current_database();") + db_name = cursor.fetchone()[0] + print(f"Connected to database: {db_name}") + + # Close the cursor and connection + cursor.close() + conn.close() + print("Connection closed successfully.") + + except Exception as e: + print(f"Error: {e}") + +if __name__ == "__main__": + test_postgis_connection()