Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Database Management System Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bouchaira Neirouz
Database Management System Project
Commits
97a44e08
You need to sign in or sign up before continuing.
Commit
97a44e08
authored
7 months ago
by
Bouchaira Neirouz
Browse files
Options
Downloads
Patches
Plain Diff
questions
parent
68f9ca30
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
donnees/Questions 3 et 4.ipynb
+18
-0
18 additions, 0 deletions
donnees/Questions 3 et 4.ipynb
donnees/Questions 5 et 6.ipynb
+187
-9
187 additions, 9 deletions
donnees/Questions 5 et 6.ipynb
with
205 additions
and
9 deletions
donnees/Questions 3 et 4.ipynb
0 → 100644
+
18
−
0
View file @
97a44e08
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:code id: tags:
```
```
This diff is collapsed.
Click to expand it.
donnees/Questions 5 et 6.ipynb
+
187
−
9
View file @
97a44e08
...
...
@@ -2,9 +2,17 @@
"cells": [
{
"cell_type": "code",
"execution_count":
null
,
"execution_count":
2
,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Connected to company.db\n"
]
}
],
"source": [
"import sqlite3\n",
"\n",
...
...
@@ -26,9 +34,96 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>NUMERO_EMPLOYE</th>\n",
" <th>NOM</th>\n",
" <th>PRENOM</th>\n",
" <th>DATE_DEBUT</th>\n",
" <th>PRIME_NOEL</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>Dubois</td>\n",
" <td>Michel</td>\n",
" <td>2020-11-13</td>\n",
" <td>2160.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>Bouchaira</td>\n",
" <td>Neirouz</td>\n",
" <td>2021-11-13</td>\n",
" <td>2160.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>Caty</td>\n",
" <td>Jeanne</td>\n",
" <td>2019-11-03</td>\n",
" <td>3712.50</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>5</td>\n",
" <td>Mourin</td>\n",
" <td>Julie</td>\n",
" <td>2023-11-13</td>\n",
" <td>2126.25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>7</td>\n",
" <td>Jura</td>\n",
" <td>Charlie</td>\n",
" <td>2022-11-28</td>\n",
" <td>3712.50</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" NUMERO_EMPLOYE NOM PRENOM DATE_DEBUT PRIME_NOEL\n",
"0 1 Dubois Michel 2020-11-13 2160.00\n",
"1 2 Bouchaira Neirouz 2021-11-13 2160.00\n",
"2 3 Caty Jeanne 2019-11-03 3712.50\n",
"3 5 Mourin Julie 2023-11-13 2126.25\n",
"4 7 Jura Charlie 2022-11-28 3712.50"
]
},
"execution_count": 5,
"metadata": {},
"outputs": [],
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"from datetime import datetime, timedelta\n",
...
...
@@ -60,12 +155,12 @@
" if CS_JOURNEE is not None:\n",
" cursor.execute(f\"SELECT SALAIRE_SEMAINE_BASE FROM GRILLE_SALAIRE_HORAIRE WHERE CS_HORAIRE = {CS_JOURNEE}\")\n",
" salaire_base=cursor.fetchone()[0]\n",
" prime_noel= salaire_base
* 100
* delta.days / 365 \n",
" prime_noel=
max(0,
salaire_base * delta.days / 365
)
\n",
" prime_partielle.append((NUMERO_EMPLOYE, NOM, PRENOM, DATE_DEBUT, prime_noel))\n",
" if CS_PRODUCTION is not None:\n",
" cursor.execute(f\"SELECT SALAIRE_SEMAINE_BASE FROM GRILLE_SALAIRE_PROD WHERE CS_PRODUCTION = {CS_PRODUCTION}\")\n",
" salaire_base=cursor.fetchone()[0]\n",
" prime_noel= salaire_base*100 * delta.days / 365 \n",
" prime_noel=
max(0,
salaire_base*100 * delta.days / 365
)
\n",
" prime_partielle.append((NUMERO_EMPLOYE, NOM, PRENOM, DATE_DEBUT, prime_noel))\n",
"\n",
"\n",
...
...
@@ -77,17 +172,100 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>NUMERO_EMPLOYE</th>\n",
" <th>NOM</th>\n",
" <th>PRENOM</th>\n",
" <th>DATE_DEBUT</th>\n",
" <th>PRIME_NOEL</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>6</td>\n",
" <td>Bowers</td>\n",
" <td>Matthew</td>\n",
" <td>2024-11-20</td>\n",
" <td>46.027397</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>8</td>\n",
" <td>Fabien</td>\n",
" <td>Dupont</td>\n",
" <td>2025-01-31</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>9</td>\n",
" <td>Philippe</td>\n",
" <td>Philip</td>\n",
" <td>2025-03-21</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" NUMERO_EMPLOYE NOM PRENOM DATE_DEBUT PRIME_NOEL\n",
"0 6 Bowers Matthew 2024-11-20 46.027397\n",
"1 8 Fabien Dupont 2025-01-31 0.000000\n",
"2 9 Philippe Philip 2025-03-21 0.000000"
]
},
"execution_count": 6,
"metadata": {},
"outputs": [],
"output_type": "execute_result"
}
],
"source": [
"prime_partielle.head()"
]
}
],
"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
import
sqlite3
# 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:markdown id: tags:
# Requêtes SQL 5 et 6
%% Cell type:code id: tags:
```
```
python
import
pandas
as
pd
from
datetime
import
datetime
,
timedelta
chrismas_day
=
datetime
(
2024
,
12
,
25
)
cursor
.
execute
(
"
SELECT NUMERO_EMPLOYE, NOM, PRENOM, CS_PRODUCTION,CS_JOURNEE, DATE_DEBUT FROM EMPLOYE
"
)
employees
=
cursor
.
fetchall
()
# Create a list to store the data
prime_totale
=
[]
prime_partielle
=
[]
# Calculate the prime de noel for each employee
for
employee
in
employees
:
NUMERO_EMPLOYE
,
NOM
,
PRENOM
,
CS_PRODUCTION
,
CS_JOURNEE
,
DATE_DEBUT
=
employee
start_date
=
datetime
.
strptime
(
DATE_DEBUT
,
'
%Y-%m-%d
'
)
delta
=
chrismas_day
-
start_date
if
delta
.
days
>=
365
:
if
CS_JOURNEE
is
not
None
:
cursor
.
execute
(
f
"
SELECT SALAIRE_SEMAINE_BASE FROM GRILLE_SALAIRE_HORAIRE WHERE CS_HORAIRE =
{
CS_JOURNEE
}
"
)
salaire_base
=
cursor
.
fetchone
()[
0
]
prime_noel
=
salaire_base
*
4.5
prime_totale
.
append
((
NUMERO_EMPLOYE
,
NOM
,
PRENOM
,
DATE_DEBUT
,
prime_noel
))
if
CS_PRODUCTION
is
not
None
:
cursor
.
execute
(
f
"
SELECT SALAIRE_SEMAINE_BASE FROM GRILLE_SALAIRE_PROD WHERE CS_PRODUCTION =
{
CS_PRODUCTION
}
"
)
salaire_base
=
cursor
.
fetchone
()[
0
]
prime_noel
=
salaire_base
*
4.5
prime_totale
.
append
((
NUMERO_EMPLOYE
,
NOM
,
PRENOM
,
DATE_DEBUT
,
prime_noel
))
else
:
if
CS_JOURNEE
is
not
None
:
cursor
.
execute
(
f
"
SELECT SALAIRE_SEMAINE_BASE FROM GRILLE_SALAIRE_HORAIRE WHERE CS_HORAIRE =
{
CS_JOURNEE
}
"
)
salaire_base
=
cursor
.
fetchone
()[
0
]
prime_noel= salaire_base
* 100
* delta.days / 365
prime_noel
=
max
(
0
,
salaire_base
*
delta
.
days
/
365
)
prime_partielle
.
append
((
NUMERO_EMPLOYE
,
NOM
,
PRENOM
,
DATE_DEBUT
,
prime_noel
))
if
CS_PRODUCTION
is
not
None
:
cursor
.
execute
(
f
"
SELECT SALAIRE_SEMAINE_BASE FROM GRILLE_SALAIRE_PROD WHERE CS_PRODUCTION =
{
CS_PRODUCTION
}
"
)
salaire_base
=
cursor
.
fetchone
()[
0
]
prime_noel= salaire_base*100 * delta.days / 365
prime_noel
=
max
(
0
,
salaire_base
*
100
*
delta
.
days
/
365
)
prime_partielle
.
append
((
NUMERO_EMPLOYE
,
NOM
,
PRENOM
,
DATE_DEBUT
,
prime_noel
))
# Create the dataframe
prime_totale
=
pd
.
DataFrame
(
prime_totale
,
columns
=
[
'
NUMERO_EMPLOYE
'
,
'
NOM
'
,
'
PRENOM
'
,
'
DATE_DEBUT
'
,
'
PRIME_NOEL
'
])
prime_partielle
=
pd
.
DataFrame
(
prime_partielle
,
columns
=
[
'
NUMERO_EMPLOYE
'
,
'
NOM
'
,
'
PRENOM
'
,
'
DATE_DEBUT
'
,
'
PRIME_NOEL
'
])
prime_totale
.
head
()
```
%% Output
NUMERO_EMPLOYE NOM PRENOM DATE_DEBUT PRIME_NOEL
0 1 Dubois Michel 2020-11-13 2160.00
1 2 Bouchaira Neirouz 2021-11-13 2160.00
2 3 Caty Jeanne 2019-11-03 3712.50
3 5 Mourin Julie 2023-11-13 2126.25
4 7 Jura Charlie 2022-11-28 3712.50
%% Cell type:code id: tags:
```
```
python
prime_partielle
.
head
()
```
%% Output
NUMERO_EMPLOYE NOM PRENOM DATE_DEBUT PRIME_NOEL
0 6 Bowers Matthew 2024-11-20 46.027397
1 8 Fabien Dupont 2025-01-31 0.000000
2 9 Philippe Philip 2025-03-21 0.000000
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment