Temps execution

Résolu
s.pastour Messages postés 14 Date d'inscription   Statut Membre Dernière intervention   -  
yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,

J'ai un programme en python qui execute des fonctions sur la base de donnée mais ces données sont très volumineuse.

Je voudrais créer un chronomètre qui se termine quand la dernière fonction a été réaliser mais je vois pas comment faire.

voici mon code :
"conn=psycopg2.connect(host=hote,user=utilisateur,password=mot_passe,dbname=dbname)

cur=conn.cursor()

try:
cur.execute("select fn_inra_suivie('apd_aveyron')")
tab_infra_suivie=cur.fetchall()
print(tab_infra_suivie[0])
conn.commit()
except Exception as e:
print(e)

try:
cur.execute("select fn_info_cable('apd_aveyron',"+str(tolerence)+")")
tab_info_cable=cur.fetchall()
print(tab_info_cable[0])
conn.commit()
except Exception as e:
print(e)

try:
cur.execute("select fn_lot8_boite('apd_aveyron')")
tab_lot8_boite=cur.fetchall()
print(tab_lot8_boite[0])
conn.commit()
except Exception as e:
print(e)

try:
cur.execute("select fn_lot8_apd_cable('apd_aveyron',"+str(tolerence)+")")
tab_lot8_cable=cur.fetchall()
print(tab_lot8_cable[0])
conn.commit()
except Exception as e:
print(e)
"""
try:
cur.execute("select fn_tableau_livrable('apd_aveyron',"+str(tolerence)+")")
tab_livrable=cur.fetchall()
print(tab_livrable[0])
conn.commit()
except Exception as e:
print(e)
"""
try:
cur.execute("select public.suivi_traveaux('aveyron',"+str(tolerence)+")")
tab_livrable=cur.fetchall()
print(tab_livrable[0],'FIN')
conn.commit()
except Exception as e:
print(e)

try:
cur.execute('select ref_cable from apd_aveyron.ftth_cable where code_proje is null')
tab_cb=cur.fetchall()
with open('logg/cable_ss_projet_aveyron.txt','w') as fi:
for cb in tab_cb:
fi.write(str(cb[0])+'\n')

except Exception as e:
print(e)
conn.commit()
conn.close()"

Merci pour votre aide

1 réponse

yg_be Messages postés 23541 Date d'inscription   Statut Contributeur Dernière intervention   Ambassadeur 1 584
 
bonjour, un exemple:
from datetime import *
depart = datetime.now()
input("...")
arrivee=datetime.now()
ecoule=arrivee-depart
print(ecoule)
1