diff --git a/PC/FileToSql.py b/PC/FileToSql.py
index 1cd0f55d619c9ca5f846e2a116aa4a54c8829c30..449ca798cd111b367a9844db90667f1b516402c5 100644
--- a/PC/FileToSql.py
+++ b/PC/FileToSql.py
@@ -3,26 +3,43 @@ import time
 import sys
 import os
 import csv
+import shutil
+from datetime import datetime
 
-db = MySQLdb.connect(host="localhost",#"pil-09.univlehavre.lan",   
-                     user="firediag",         
-                     passwd="firediag$!",  
-                     db="firediag");
+log = open("logBDD.txt", "w")
 
-nomCapteur = "Moule A"
+try:
+	db = MySQLdb.connect(host="localhost",#"pil-09.univlehavre.lan",   
+		             user="firediag",         
+		             passwd="firediag$!",  
+		             db="firediag");
+except Exception as ex:
+	log.write(str(datetime.now())+" ==> Exception Demarrage : "+str(type(ex))+" ("+str(ex.args)+")\n")
+	print(ex);
+	log.close()
+	sys.exit(1)
+
+nomCapteur = "Moule A" # A0 / A1 / A2 / A3 / A4 / A5
 tabId = {}
 
-#--- Recupere les id des capteurs en base de donnees
-for i in range(0,6):
-	requete = "SELECT DISTINCT id FROM capteur WHERE nom = '"+nomCapteur+""+str(i)+"'"
-	cursor = db.cursor();
-	cursor.execute(requete)
-	idTab = cursor.fetchall()
-	tabId["A"+str(i)] = int(idTab[0][0])
+try:
+	#--- Recupere les id des capteurs en base de donnees
+	for i in range(0,6):
+		requete = "SELECT DISTINCT id FROM capteur WHERE nom = '"+nomCapteur+""+str(i)+"'"
+		cursor = db.cursor();
+		cursor.execute(requete)
+		idTab = cursor.fetchall()
+		tabId["A"+str(i)] = int(idTab[0][0])
+except Exception as ex:
+	log.write(str(datetime.now())+" ==> Exception Init : "+str(type(ex))+" ("+str(ex.args)+")\n")
+	print(ex);
+	log.close()
+	sys.exit(1)
 
 print(tabId)
 
 FOLDER = "./data/"
+TRAITEES = "./traitees/"
 DIR = os.listdir(FOLDER)
 DIR.sort()
 
@@ -30,9 +47,9 @@ cursor = db.cursor();
 
 #--- Parcours les fichiers, ajoute les valeurs en base et supprime le fichier 
 for f in DIR:
-	try:	
-		print(FOLDER+f)
-		with open(FOLDER+f,'r') as csvfile:			
+	print(FOLDER+f)
+	with open(FOLDER+f,'r') as csvfile:			
+		try:
 			#--- Recupere la source du fichier		
 			id = csvfile.readline().strip().split(":")[1]
 			print(id)
@@ -47,9 +64,14 @@ for f in DIR:
 					requete = "INSERT INTO `valeur` (`temps`, `valeur`, `idCapteur`) VALUES ('"+str(time).strip()+"', '"+str(row[i+1]).strip()+"', '"+str(tabId["A"+str(i)])+"')"
 					cursor.execute(requete)
 				#print(row)
-		db.commit();
-		os.remove(FOLDER+f)
-	except Exception as e:
-		db.rollback();
-		print("rollback ");
-		print(e);
+		except Exception as ex:
+			db.rollback();
+			log.write(str(datetime.now())+" ==> Exception Requete : "+str(type(ex))+" ("+str(ex.args)+")\n")
+			print("rollback ");
+			print(ex);	
+	db.commit();
+	#os.remove(FOLDER+f)
+	shutil.move(FOLDER+f, TRAITEES+f)
+
+db.close();
+log.close()
diff --git a/PC/server.py b/PC/server.py
index 23aa60ed3ccd0bb35e6b3dfeb2586d8ba0d3c264..83a88445a2bdbeef44b2bc1115930c3abbbd321e 100644
--- a/PC/server.py
+++ b/PC/server.py
@@ -6,7 +6,7 @@ from datetime import datetime
 
 CHUNK_SIZE = 2048
 PORT = 20000
-log = open("log.txt", "w")
+log = open("logServer.txt", "w")
 file = None
 
 while True: