Temps execution

Résolu/Fermé
s.pastour Messages postés 16 Date d'inscription jeudi 3 mai 2018 Statut Membre Dernière intervention 3 février 2021 - 21 oct. 2020 à 10:28
yg_be Messages postés 23476 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 20 février 2025 - 21 oct. 2020 à 13:23
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 23476 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 20 février 2025 Ambassadeur 1 568
21 oct. 2020 à 13:23
bonjour, un exemple:
from datetime import *
depart = datetime.now()
input("...")
arrivee=datetime.now()
ecoule=arrivee-depart
print(ecoule)
1