Skip to content

Commit

Permalink
Mise à jour du 08/10/2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Soumaya-JE authored Oct 8, 2024
1 parent fa619cd commit 0060d71
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/app/db_service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /app
# Copier les fichiers de l'application dans le conteneur
COPY main.py /app/
COPY data_fictive_drifted.csv /app/
COPY run_insertion.sh /app/
#COPY run_insertion.sh /app/
COPY requirements.txt /app/
COPY last_inserted_line.txt /app/

Expand All @@ -27,11 +27,11 @@ RUN pip install --no-cache-dir -r requirements.txt
# Installer pandas explicitement
RUN pip install pandas

# Donner les droits d'exécution au script bash
RUN chmod +x /app/run_insertion.sh
# Donner les droits d'exécution au script Python
RUN chmod +x /app/main.py

# Créer un nouveau cron job qui exécute le script toutes les minutes
RUN echo "* * * * * root /app/run_insertion.sh >> /var/log/cron.log 2>&1" > /etc/cron.d/insertion-cron
RUN echo "* * * * * root /usr/local/bin/python /app/main.py >> /var/log/cron.log 2>&1" > /etc/cron.d/insertion-cron

# Appliquer les permissions correctes au fichier cron job
RUN chmod 0644 /etc/cron.d/insertion-cron
Expand Down
Empty file.
7 changes: 4 additions & 3 deletions src/app/db_service/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env python3
import pandas as pd
import psycopg2
from datetime import datetime
import os
import numpy as np

# Chemin du fichier CSV
csv_file_path = 'data_fictive_drifted.csv'
csv_file_path = '/app/data_fictive_drifted.csv'

# Chemin du fichier de suivi de la dernière ligne insérée
last_inserted_file = 'last_inserted_line.txt'
last_inserted_file = '/app/last_inserted_line.txt'

# Charger le fichier CSV
df = pd.read_csv(csv_file_path)
Expand Down Expand Up @@ -55,7 +56,7 @@
# Connexion à la base de données PostgreSQL
try:
conn = psycopg2.connect(
host="localhost",
host="db",
port="5432",
dbname="accidents",
user="my_user",
Expand Down

0 comments on commit 0060d71

Please sign in to comment.