Skip to content

Commit

Permalink
add SSH
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRunfola committed Dec 17, 2024
1 parent b49ae33 commit 514211f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
Empty file.
6 changes: 4 additions & 2 deletions geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
49 changes: 49 additions & 0 deletions geoBoundaryBuilder/scripts/A_sourceIngest.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 514211f

Please sign in to comment.