" cursor.execute(\"SELECT * FROM SALAIRE_SEMAINE where DATE_LUNDI=? and NUMERO_EMPLOYE=?\", (date,NUMERO_EMPLOYE))\n",
" semaine=cursor.fetchall()\n",
" if semaine ==[] and CS_JOURNEE is not None:\n",
" liste_jours_travail=[]\n",
" for j in range(2,8):\n",
" cursor.execute(\"SELECT * FROM LOG_JOURNEE_JOUR where DATE=? and NUMERO_EMPLOYE=?\", ((datetime.datetime.strptime(date, \"%Y-%m-%d\") - datetime.timedelta(days=j)).strftime(\"%Y-%m-%d\"), NUMERO_EMPLOYE))\n",
" jour=cursor.fetchall()\n",
" liste_jours_travail.insert(0, jour)\n",
" if liste_jours_travail!=[[], [], [], [], [], []]:\n",
" for k in liste_jours_travail:\n",
" nb_heures=0\n",
" if k!=[]:\n",
" nb_heures=+k[0][6]\n",
" print(nb_heures)\n",
" cursor.execute(f\"SELECT SALAIRE_HORAIRE FROM GRILLE_SALAIRE_HORAIRE WHERE CS_HORAIRE = {CS_JOURNEE}\")\n",
" salaire_horaire=cursor.fetchone()[0]\n",
" cursor.execute(\"INSERT INTO SALAIRE_SEMAINE (DATE_LUNDI,NUMERO_EMPLOYE,NB_HEURES, NB_PRODUCTION,SALAIRE_AVANT,NOEL,ANCIENNETE,SALAIRE_APRES) VALUES (?,?,?,?,?,?,?,?)\", (date,NUMERO_EMPLOYE,nb_heures,0,salaire_horaire*nb_heures,0,0,0))\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
}
},
"nbformat": 4,
...
...
%% Cell type:code id: tags:
```
``` python
importsqlite3
# Connect to the database
conn=sqlite3.connect('company.db')
# Create a cursor object
cursor=conn.cursor()
print("Connected to company.db")
```
%% Output
Connected to company.db
%% Cell type:code id: tags:
``` python
# Journées
importdatetime
cursor.execute("SELECT NUMERO_EMPLOYE, NOM, PRENOM, CS_PRODUCTION,CS_JOURNEE, DATE_DEBUT FROM EMPLOYE")
cursor.execute("SELECT * FROM SALAIRE_SEMAINE where DATE_LUNDI=? and NUMERO_EMPLOYE=?",(date,NUMERO_EMPLOYE))
semaine=cursor.fetchall()
ifsemaine==[]andCS_JOURNEEisnotNone:
liste_jours_travail=[]
forjinrange(2,8):
cursor.execute("SELECT * FROM LOG_JOURNEE_JOUR where DATE=? and NUMERO_EMPLOYE=?",((datetime.datetime.strptime(date,"%Y-%m-%d")-datetime.timedelta(days=j)).strftime("%Y-%m-%d"),NUMERO_EMPLOYE))
jour=cursor.fetchall()
liste_jours_travail.insert(0,jour)
ifliste_jours_travail!=[[],[],[],[],[],[]]:
forkinliste_jours_travail:
nb_heures=0
ifk!=[]:
nb_heures=+k[0][6]
print(nb_heures)
cursor.execute(f"SELECT SALAIRE_HORAIRE FROM GRILLE_SALAIRE_HORAIRE WHERE CS_HORAIRE = {CS_JOURNEE}")
salaire_horaire=cursor.fetchone()[0]
cursor.execute("INSERT INTO SALAIRE_SEMAINE (DATE_LUNDI,NUMERO_EMPLOYE,NB_HEURES, NB_PRODUCTION,SALAIRE_AVANT,NOEL,ANCIENNETE,SALAIRE_APRES) VALUES (?,?,?,?,?,?,?,?)",(date,NUMERO_EMPLOYE,nb_heures,0,salaire_horaire*nb_heures,0,0,0))