Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dimitri Nicolas
AI23 - Projet
Commits
b3d3b3d5
Commit
b3d3b3d5
authored
Jun 25, 2021
by
Marine Marsal
Browse files
Update StatistiquesDataMapper.py
parent
5ea36fba
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/StatistiquesDataMapper.py
View file @
b3d3b3d5
...
...
@@ -39,7 +39,7 @@ class StatistiquesDataMapper(DataMapper):
conn
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
conn
.
cursor
()
sql1
=
"SELECT gp.
tit
re, gp.nb_emprunt FROM GenresPopulaires gp"
sql1
=
"SELECT gp.
gen
re, gp.nb_emprunt FROM GenresPopulaires gp"
cursor
.
execute
(
sql1
)
rows
=
cursor
.
fetchall
()
return
rows
...
...
@@ -49,12 +49,12 @@ class StatistiquesDataMapper(DataMapper):
conn
.
close
()
# print('Genre : {0} Nombre d\'emprunts : {1}\n'.format(row[0], row[1]))
# retourne le nombre de fois qu'un
e ressourc
e a été empruntée
def
nombreEmprunt
Ressourc
e
(
self
,
genre
:
int
)
:
# retourne le nombre de fois qu'un
genr
e a été empruntée
def
nombreEmprunt
ParGenr
e
(
self
,
genre
:
int
)
:
conn
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
conn
.
cursor
()
sql1
=
"SELECT gp.
tit
re, gp.nb_emprunt FROM GenresPopulaires gp WHERE gp.genre = '{0}' GROUP BY gp.genre"
.
format
(
genre
)
sql1
=
"SELECT gp.
gen
re, gp.nb_emprunt FROM GenresPopulaires gp WHERE gp.genre = '{0}' GROUP BY gp.genre"
.
format
(
genre
)
cursor
.
execute
(
sql1
)
ressource
=
cursor
.
fetchone
()
return
ressource
[
1
]
...
...
@@ -139,7 +139,7 @@ class StatistiquesDataMapper(DataMapper):
conn
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
conn
.
cursor
()
sql1
=
"SELECT AVG(
p.
duree) FROM Pret
p
ORDER BY AVG(
p.
duree) DESC"
sql1
=
"SELECT AVG(duree) FROM Pret ORDER BY AVG(duree) DESC"
cursor
.
execute
(
sql1
)
duree
=
cursor
.
fetchone
()
return
duree
[
0
]
...
...
@@ -165,7 +165,7 @@ class StatistiquesDataMapper(DataMapper):
conn
=
self
.
connect
()
try
:
cursor
:
psycopg2
.
extensions
.
cursor
=
conn
.
cursor
()
sql1
=
"SELECT MAX(
p.
duree) FROM Pret
p
ORDER BY MAX(
p.
duree) DESC"
sql1
=
"SELECT MAX(duree) FROM Pret ORDER BY MAX(duree) DESC"
cursor
.
execute
(
sql1
)
durees
=
cursor
.
fetchall
()
return
durees
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment