parent
13736bec78
commit
04e840d7b2
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
sed -r 's/: psycopg2\.(connection|cursor)//' tp.py > /tmp/patched_tp.py
|
||||
python3 /tmp/patched_tp.py
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@
|
||||
INSERT INTO Discipline VALUES('ARC','Archery');
|
||||
INSERT INTO Discipline VALUES('CRD','Cycling Road');
|
||||
INSERT INTO Discipline VALUES('FEN','Fencing');
|
||||
INSERT INTO Discipline VALUES('JUD','Judo');
|
||||
INSERT INTO Discipline VALUES('SHO','Shooting');
|
||||
INSERT INTO Discipline VALUES('TKW','Taekwondo');
|
||||
INSERT INTO Discipline VALUES('WLF','Weightlifting');
|
||||
INSERT INTO Discipline VALUES('DIV','Diving');
|
||||
INSERT INTO Discipline VALUES('SKB','Skateboarding');
|
||||
INSERT INTO Discipline VALUES('SWM','Swimming');
|
||||
INSERT INTO Discipline VALUES('GAR','Artistic Gymnastics');
|
||||
INSERT INTO Discipline VALUES('CSL','Canoe Slalom');
|
||||
INSERT INTO Discipline VALUES('MTB','Cycling Mountain Bike');
|
||||
INSERT INTO Discipline VALUES('TTE','Table Tennis');
|
||||
INSERT INTO Discipline VALUES('TRI','Triathlon');
|
||||
INSERT INTO Discipline VALUES('BSB','Baseball/Softball');
|
||||
INSERT INTO Discipline VALUES('EQU','Equestrian');
|
||||
INSERT INTO Discipline VALUES('SRF','Surfing');
|
||||
INSERT INTO Discipline VALUES('BK3','3x3 Basketball');
|
||||
INSERT INTO Discipline VALUES('ROW','Rowing');
|
||||
INSERT INTO Discipline VALUES('RUG','Rugby Sevens');
|
||||
INSERT INTO Discipline VALUES('ATH','Athletics');
|
||||
INSERT INTO Discipline VALUES('BDM','Badminton');
|
||||
INSERT INTO Discipline VALUES('BMX','Cycling BMX Racing');
|
||||
INSERT INTO Discipline VALUES('TEN','Tennis');
|
||||
INSERT INTO Discipline VALUES('GTR','Trampoline Gymnastics');
|
||||
INSERT INTO Discipline VALUES('BOX','Boxing');
|
||||
INSERT INTO Discipline VALUES('SAL','Sailing');
|
||||
INSERT INTO Discipline VALUES('BMF','Cycling BMX Freestyle');
|
||||
INSERT INTO Discipline VALUES('GLF','Golf');
|
||||
INSERT INTO Discipline VALUES('CTR','Cycling Track');
|
||||
INSERT INTO Discipline VALUES('WRE','Wrestling');
|
||||
INSERT INTO Discipline VALUES('CSP','Canoe Sprint');
|
||||
INSERT INTO Discipline VALUES('SWA','Artistic Swimming');
|
||||
INSERT INTO Discipline VALUES('OWS','Marathon Swimming');
|
||||
INSERT INTO Discipline VALUES('HOC','Hockey');
|
||||
INSERT INTO Discipline VALUES('KTE','Karate');
|
||||
INSERT INTO Discipline VALUES('CLB','Sport Climbing');
|
||||
INSERT INTO Discipline VALUES('VBV','Beach Volleyball');
|
||||
INSERT INTO Discipline VALUES('FBL','Football');
|
||||
INSERT INTO Discipline VALUES('MPN','Modern Pentathlon');
|
||||
INSERT INTO Discipline VALUES('BKB','Basketball');
|
||||
INSERT INTO Discipline VALUES('HBL','Handball');
|
||||
INSERT INTO Discipline VALUES('GRY','Rhythmic Gymnastics');
|
||||
INSERT INTO Discipline VALUES('VVO','Volleyball');
|
||||
INSERT INTO Discipline VALUES('WPO','Water Polo');
|
@ -0,0 +1,355 @@
|
||||
INSERT INTO Epreuve VALUES('E001','ARC','Mixed Team','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E002','CRD','Men''s Road Race','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E003','FEN','Men''s Sabre Individual','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E004','FEN','Women''s Epée Individual','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E005','JUD','Men -60 kg','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E006','JUD','Women -48 kg','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E007','SHO','10m Air Pistol Men','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E008','SHO','10m Air Rifle Women','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E009','TKW','Men -58kg','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E010','TKW','Women -49kg','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E011','WLF','Women''s 49kg','2021-07-24'::date);
|
||||
INSERT INTO Epreuve VALUES('E012','ARC','Women''s Team','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E013','CRD','Women''s Road Race','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E014','DIV','Women''s Synchronised 3m Springboard','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E015','FEN','Men''s Epée Individual','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E016','FEN','Women''s Foil Individual','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E017','JUD','Men -66 kg','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E018','JUD','Women -52 kg','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E019','SHO','10m Air Pistol Women','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E020','SHO','10m Air Rifle Men','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E021','SKB','Men''s Street','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E022','SWM','Men''s 400m Freestyle','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E023','SWM','Men''s 400m Individual Medley','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E024','SWM','Women''s 4 x 100m Freestyle Relay','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E025','SWM','Women''s 400m Individual Medley','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E026','TKW','Men -68kg','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E027','TKW','Women -57kg','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E028','WLF','Men''s 61kg','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E029','WLF','Men''s 67kg','2021-07-25'::date);
|
||||
INSERT INTO Epreuve VALUES('E030','ARC','Men''s Team','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E031','GAR','Men''s Team','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E032','CSL','Men''s Canoe','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E033','MTB','Men''s Cross-country','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E034','DIV','Men''s Synchronised 10m Platform','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E035','FEN','Men''s Foil Individual','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E036','FEN','Women''s Sabre Individual','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E037','JUD','Men -73 kg','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E038','JUD','Women -57 kg','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E039','SHO','Skeet Men','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E040','SHO','Skeet Women','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E041','SKB','Women''s Street','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E042','SWM','Men''s 100m Breaststroke','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E043','SWM','Men''s 4 x 100m Freestyle Relay','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E044','SWM','Women''s 100m Butterfly','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E045','SWM','Women''s 400m Freestyle','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E046','TTE','Mixed Doubles','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E047','TKW','Men -80kg','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E048','TKW','Women -67kg','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E049','TRI','Men''s Individual','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E050','WLF','Women''s 55kg','2021-07-26'::date);
|
||||
INSERT INTO Epreuve VALUES('E051','GAR','Women''s Team','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E052','BSB','Softball','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E053','CSL','Women''s Kayak','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E054','MTB','Women''s Cross-country','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E055','DIV','Women''s Synchronised 10m Platform','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E056','EQU','Dressage Team','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E057','FEN','Women''s Epée Team','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E058','JUD','Men -81 kg','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E059','JUD','Women -63 kg','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E060','SHO','10m Air Pistol Mixed Team','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E061','SHO','10m Air Rifle Mixed Team','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E062','SRF','Men','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E063','SRF','Women','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E064','SWM','Men''s 100m Backstroke','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E065','SWM','Men''s 200m Freestyle','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E066','SWM','Women''s 100m Backstroke','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E067','SWM','Women''s 100m Breaststroke','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E068','TKW','Men +80kg','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E069','TKW','Women +67kg','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E070','TRI','Women''s Individual','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E071','WLF','Women''s 59kg','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E072','WLF','Women''s 64kg','2021-07-27'::date);
|
||||
INSERT INTO Epreuve VALUES('E073','BK3','Men','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E074','BK3','Women','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E075','GAR','Men''s All-Around','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E076','CRD','Men''s Individual Time Trial','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E077','CRD','Women''s Individual Time Trial','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E078','DIV','Men''s Synchronised 3m Springboard','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E079','EQU','Dressage Individual','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E080','FEN','Men''s Sabre Team','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E081','JUD','Men -90 kg','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E082','JUD','Women -70 kg','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E083','ROW','Men''s Double Sculls','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E084','ROW','Men''s Four','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E085','ROW','Men''s Quadruple Sculls','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E086','ROW','Women''s Double Sculls','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E087','ROW','Women''s Four','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E088','ROW','Women''s Quadruple Sculls','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E089','RUG','Men','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E090','SWM','Men''s 200m Butterfly','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E091','SWM','Men''s 4 x 200m Freestyle Relay','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E092','SWM','Women''s 1500m Freestyle','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E093','SWM','Women''s 200m Freestyle','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E094','SWM','Women''s 200m Individual Medley','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E095','WLF','Men''s 73kg','2021-07-28'::date);
|
||||
INSERT INTO Epreuve VALUES('E096','GAR','Women''s All-Around','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E097','CSL','Women''s Canoe','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E098','FEN','Women''s Foil Team','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E099','JUD','Men -100 kg','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E100','JUD','Women -78 kg','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E101','ROW','Lightweight Men''s Double Sculls','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E102','ROW','Lightweight Women''s Double Sculls','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E103','ROW','Men''s Pair','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E104','ROW','Women''s Pair','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E105','SHO','Trap Men','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E106','SHO','Trap Women','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E107','SWM','Men''s 100m Freestyle','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E108','SWM','Men''s 200m Breaststroke','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E109','SWM','Men''s 800m Freestyle','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E110','SWM','Women''s 200m Butterfly','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E111','SWM','Women''s 4 x 200m Freestyle Relay','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E112','TTE','Women''s Singles','2021-07-29'::date);
|
||||
INSERT INTO Epreuve VALUES('E113','ARC','Women''s Individual','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E114','ATH','Men''s 10,000m','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E115','BDM','Mixed Doubles','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E116','CSL','Men''s Kayak','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E117','BMX','Men','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E118','BMX','Women','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E119','FEN','Men''s Epée Team','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E120','JUD','Men +100 kg','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E121','JUD','Women +78 kg','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E122','ROW','Men''s Eight','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E123','ROW','Men''s Single Sculls','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E124','ROW','Women''s Eight','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E125','ROW','Women''s Single Sculls','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E126','SHO','25m Pistol Women','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E127','SWM','Men''s 200m Backstroke','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E128','SWM','Men''s 200m Individual Medley','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E129','SWM','Women''s 100m Freestyle','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E130','SWM','Women''s 200m Breaststroke','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E131','TTE','Men''s Singles','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E132','TEN','Men''s Doubles','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E133','GTR','Women','2021-07-30'::date);
|
||||
INSERT INTO Epreuve VALUES('E134','ARC','Men''s Individual','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E135','ATH','4 x 400m Relay Mixed','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E136','ATH','Men''s Discus Throw','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E137','ATH','Women''s 100m','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E138','BDM','Men''s Doubles','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E139','BOX','Women''s Feather (54-57kg)','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E140','FEN','Women''s Sabre Team','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E141','JUD','Mixed Team','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E142','RUG','Women','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E143','SAL','Men''s Windsurfer - RS:X','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E144','SAL','Women''s Windsurfer - RS:X','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E145','SHO','50m Rifle 3 Positions Women','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E146','SHO','Trap Mixed Team','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E147','SWM','Men''s 100m Butterfly','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E148','SWM','Mixed 4 x 100m Medley Relay','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E149','SWM','Women''s 200m Backstroke','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E150','SWM','Women''s 800m Freestyle','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E151','TEN','Men''s Singles','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E152','TEN','Mixed Doubles','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E153','TEN','Women''s Doubles','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E154','TEN','Women''s Singles','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E155','GTR','Men','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E156','TRI','Mixed Relay','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E157','WLF','Men''s 81kg','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E158','WLF','Men''s 96kg','2021-07-31'::date);
|
||||
INSERT INTO Epreuve VALUES('E159','GAR','Men''s Floor Exercise','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E160','GAR','Men''s Pommel Horse','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E161','GAR','Women''s Uneven Bars','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E162','GAR','Women''s Vault','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E163','ATH','Men''s 100m','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E164','ATH','Men''s High Jump','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E165','ATH','Women''s Shot Put','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E166','ATH','Women''s Triple Jump','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E167','BDM','Women''s Singles','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E168','BOX','Men''s Light Heavy (75-81kg)','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E169','BOX','Men''s Welter (63-69kg)','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E170','BMF','Men''s Park','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E171','BMF','Women''s Park','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E172','DIV','Women''s 3m Springboard','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E173','FEN','Men''s Foil Team','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E174','GLF','Men''s Individual Stroke Play','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E175','SAL','Men''s One Person Dinghy - Laser','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E176','SAL','Women''s One Person Dinghy - Laser Radial','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E177','SWM','Men''s 1500m Freestyle','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E178','SWM','Men''s 4 x 100m Medley Relay','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E179','SWM','Men''s 50m Freestyle','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E180','SWM','Women''s 4 x 100m Medley Relay','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E181','SWM','Women''s 50m Freestyle','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E182','TEN','Men''s Singles','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E183','TEN','Mixed Doubles','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E184','TEN','Women''s Doubles','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E185','WLF','Women''s 76kg','2021-08-01'::date);
|
||||
INSERT INTO Epreuve VALUES('E186','GAR','Men''s Rings','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E187','GAR','Men''s Vault','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E188','GAR','Women''s Floor Exercise','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E189','ATH','Men''s 3000m Steeplechase','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E190','ATH','Men''s Long Jump','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E191','ATH','Women''s 100m Hurdles','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E192','ATH','Women''s 5000m','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E193','ATH','Women''s Discus Throw','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E194','BDM','Men''s Singles','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E195','BDM','Women''s Doubles','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E196','CTR','Women''s Team Sprint','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E197','EQU','Eventing Individual','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E198','EQU','Eventing Team','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E199','SHO','25m Rapid Fire Pistol Men','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E200','SHO','50m Rifle 3 Positions Men','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E201','WLF','Women''s +87kg','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E202','WLF','Women''s 87kg','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E203','WRE','Men''s Greco-Roman 130kg','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E204','WRE','Men''s Greco-Roman 60kg','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E205','WRE','Women''s Freestyle 76kg','2021-08-02'::date);
|
||||
INSERT INTO Epreuve VALUES('E206','GAR','Men''s Horizontal Bar','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E207','GAR','Men''s Parallel Bars','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E208','GAR','Women''s Balance Beam','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E209','ATH','Men''s 400m Hurdles','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E210','ATH','Men''s Pole Vault','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E211','ATH','Women''s 200m','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E212','ATH','Women''s 800m','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E213','ATH','Women''s Hammer Throw','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E214','ATH','Women''s Long Jump','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E215','BOX','Men''s Feather (52-57kg)','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E216','BOX','Men''s Heavy (81-91kg)','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E217','BOX','Men''s Welter (63-69kg)','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E218','BOX','Women''s Feather (54-57kg)','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E219','CSP','Men''s Canoe Double 1000m','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E220','CSP','Men''s Kayak Single 1000m','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E221','CSP','Women''s Kayak Double 500m','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E222','CSP','Women''s Kayak Single 200m','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E223','CTR','Men''s Team Sprint','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E224','CTR','Women''s Team Pursuit','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E225','DIV','Men''s 3m Springboard','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E226','SAL','Men''s One Person Dinghy (Heavyweight) - Finn','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E227','SAL','Men''s Skiff - 49er','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E228','SAL','Mixed Multihull - Nacra 17 Foiling','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E229','SAL','Women''s Skiff - 49er FX','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E230','WLF','Men''s 109kg','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E231','WRE','Men''s Greco-Roman 77kg','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E232','WRE','Men''s Greco-Roman 97kg','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E233','WRE','Women''s Freestyle 68kg','2021-08-03'::date);
|
||||
INSERT INTO Epreuve VALUES('E234','SWA','Duet','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E235','ATH','Men''s 200m','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E236','ATH','Men''s 800m','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E237','ATH','Men''s Decathlon','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E238','ATH','Men''s Hammer Throw','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E239','ATH','Women''s 3000m Steeplechase','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E240','ATH','Women''s 400m Hurdles','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E241','ATH','Women''s Heptathlon','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E242','BOX','Men''s Light Heavy (75-81kg)','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E243','BOX','Men''s Super Heavy (+91kg)','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E244','BOX','Women''s Fly (48-51kg)','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E245','BOX','Women''s Welter (64-69kg)','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E246','CTR','Men''s Team Pursuit','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E247','EQU','Jumping Individual','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E248','OWS','Women''s 10km','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E249','SAL','Men''s Two Person Dinghy - 470','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E250','SAL','Women''s Two Person Dinghy - 470','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E251','SKB','Women''s Park','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E252','WLF','Men''s +109kg','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E253','WRE','Men''s Greco-Roman 67kg','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E254','WRE','Men''s Greco-Roman 87kg','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E255','WRE','Women''s Freestyle 62kg','2021-08-04'::date);
|
||||
INSERT INTO Epreuve VALUES('E256','ATH','Men''s 110m Hurdles','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E257','ATH','Men''s 20km Race Walk','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E258','ATH','Men''s 400m','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E259','ATH','Men''s Shot Put','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E260','ATH','Men''s Triple Jump','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E261','ATH','Women''s Pole Vault','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E262','BOX','Men''s Feather (52-57kg)','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E263','BOX','Men''s Fly (48-52kg)','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E264','BOX','Men''s Middle (69-75kg)','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E265','BOX','Women''s Light (57-60kg)','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E266','CSP','Men''s Kayak Double 1000m','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E267','CSP','Men''s Kayak Single 200m','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E268','CSP','Women''s Canoe Single 200m','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E269','CSP','Women''s Kayak Single 500m','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E270','CTR','Men''s Omnium','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E271','CTR','Women''s Keirin','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E272','DIV','Women''s 10m Platform','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E273','HOC','Men','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E274','KTE','Men''s Kumite -67kg','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E275','KTE','Women''s Kata','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E276','KTE','Women''s Kumite -55kg','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E277','OWS','Men''s 10km','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E278','SKB','Men''s Park','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E279','CLB','Men''s Combined','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E280','TTE','Women''s Team','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E281','WRE','Men''s Freestyle 57kg','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E282','WRE','Men''s Freestyle 86kg','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E283','WRE','Women''s Freestyle 57kg','2021-08-05'::date);
|
||||
INSERT INTO Epreuve VALUES('E284','ATH','Men''s 4 x 100m Relay','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E285','ATH','Men''s 5000m','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E286','ATH','Men''s 50km Race Walk','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E287','ATH','Women''s 1500m','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E288','ATH','Women''s 20km Race Walk','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E289','ATH','Women''s 4 x 100m Relay','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E290','ATH','Women''s 400m','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E291','ATH','Women''s Javelin Throw','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E292','VBV','Women','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E293','BOX','Men''s Heavy (81-91kg)','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E294','BOX','Men''s Light (57-63kg)','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E295','BOX','Women''s Middle (69-75kg)','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E296','CTR','Men''s Sprint','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E297','CTR','Women''s Madison','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E298','FBL','Women','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E299','HOC','Women','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E300','KTE','Men''s Kata','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E301','KTE','Men''s Kumite -75kg','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E302','KTE','Women''s Kumite -61kg','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E303','MPN','Women''s Individual','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E304','CLB','Women''s Combined','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E305','TTE','Men''s Team','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E306','WRE','Men''s Freestyle 125kg','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E307','WRE','Men''s Freestyle 74kg','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E308','WRE','Women''s Freestyle 53kg','2021-08-06'::date);
|
||||
INSERT INTO Epreuve VALUES('E309','SWA','Team','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E310','ATH','Men''s 1500m','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E311','ATH','Men''s 4 x 400m Relay','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E312','ATH','Men''s Javelin Throw','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E313','ATH','Women''s 10,000m','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E314','ATH','Women''s 4 x 400m Relay','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E315','ATH','Women''s High Jump','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E316','ATH','Women''s Marathon','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E317','BSB','Baseball','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E318','BKB','Men','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E319','VBV','Men','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E320','BOX','Men''s Fly (48-52kg)','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E321','BOX','Men''s Middle (69-75kg)','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E322','BOX','Women''s Fly (48-51kg)','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E323','BOX','Women''s Welter (64-69kg)','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E324','CSP','Men''s Canoe Single 1000m','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E325','CSP','Men''s Kayak Four 500m','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E326','CSP','Women''s Canoe Double 500m','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E327','CSP','Women''s Kayak Four 500m','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E328','CTR','Men''s Madison','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E329','DIV','Men''s 10m Platform','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E330','EQU','Jumping Team','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E331','FBL','Men','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E332','GLF','Women''s Individual Stroke Play','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E333','HBL','Men','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E334','KTE','Men''s Kumite +75kg','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E335','KTE','Women''s Kumite +61kg','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E336','MPN','Men''s Individual','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E337','GRY','Individual All-Around','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E338','VVO','Men','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E339','WPO','Women','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E340','WRE','Men''s Freestyle 65kg','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E341','WRE','Men''s Freestyle 97kg','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E342','WRE','Women''s Freestyle 50kg','2021-08-07'::date);
|
||||
INSERT INTO Epreuve VALUES('E343','ATH','Men''s Marathon','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E344','BKB','Women','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E345','BOX','Men''s Light (57-63kg)','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E346','BOX','Men''s Super Heavy (+91kg)','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E347','BOX','Women''s Light (57-60kg)','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E348','BOX','Women''s Middle (69-75kg)','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E349','CTR','Men''s Keirin','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E350','CTR','Women''s Omnium','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E351','CTR','Women''s Sprint','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E352','HBL','Women','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E353','GRY','Group All-Around','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E354','VVO','Women','2021-08-08'::date);
|
||||
INSERT INTO Epreuve VALUES('E355','WPO','Men','2021-08-08'::date);
|
@ -0,0 +1,225 @@
|
||||
import pandas
|
||||
import psycopg2
|
||||
import matplotlib.pyplot as plt
|
||||
from getpass import getpass
|
||||
|
||||
filename = r'vgsales.csv'
|
||||
|
||||
db_host = input('Nom d\'hôte : ')
|
||||
if not db_host:
|
||||
db_host = 'berlin'
|
||||
db_name = input('Nom de la base de données : ')
|
||||
if not db_name:
|
||||
db_name = 'dbclfreville2'
|
||||
db_user = input('Utilisateur : ')
|
||||
if not db_user:
|
||||
db_user = 'clfreville2'
|
||||
db_password = getpass('Mot de passe : ')
|
||||
|
||||
##########
|
||||
# Partie 1
|
||||
##########
|
||||
|
||||
connection = psycopg2.connect(host=db_host, port=5432, database=db_name, user=db_user, password=db_password)
|
||||
cur = connection.cursor()
|
||||
|
||||
|
||||
def create_table(connection, filename):
|
||||
cur = connection.cursor()
|
||||
|
||||
# 2. Création et population de la table
|
||||
cur.execute("""CREATE TABLE IF NOT EXISTS plain_jeu (
|
||||
nom VARCHAR(150) NOT NULL,
|
||||
plateforme VARCHAR(10) NOT NULL,
|
||||
annee_sortie INTEGER,
|
||||
genre VARCHAR(20) NOT NULL,
|
||||
editeur VARCHAR(40) NOT NULL,
|
||||
ventes_na NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_ue NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_jp NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_autre NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_total NUMERIC(6, 2) NOT NULL DEFAULT 0, -- Redondant vu que devrait être le total des autres colonnes des ventes
|
||||
PRIMARY KEY(nom, plateforme)
|
||||
)""")
|
||||
|
||||
ventes = pandas.read_csv(filename)
|
||||
|
||||
# 3. Élimination des doublons
|
||||
df = pandas.DataFrame(ventes).drop_duplicates(subset=['Name', 'Platform'])
|
||||
|
||||
# 2. Insertions
|
||||
for row in df.itertuples():
|
||||
cur.execute("INSERT INTO plain_jeu VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);",
|
||||
(row.Name, row.Platform, int(row.Year) if not pandas.isnull(row.Year) else None, row.Genre,
|
||||
row.Publisher, row.NA_Sales, row.EU_Sales,
|
||||
row.JP_Sales, row.Other_Sales, row.Global_Sales))
|
||||
|
||||
# 5. Recherche des lignes incohérentes (par delta vu qu'il s'agit de nombre flottants)
|
||||
cur.execute("""SELECT nom, plateforme, ROUND((ventes_na + ventes_ue + ventes_jp + ventes_autre)::numeric, 2), ventes_total
|
||||
FROM plain_jeu
|
||||
WHERE ABS(ventes_na + ventes_ue + ventes_jp + ventes_autre - ventes_total) > 0.1""")
|
||||
for row in cur.fetchall():
|
||||
print(row)
|
||||
|
||||
# 6. Recalcul des ventes pour les lignes incohérentes
|
||||
cur.execute("""UPDATE plain_jeu
|
||||
SET ventes_total = ROUND((ventes_na + ventes_ue + ventes_jp + ventes_autre)::numeric, 2)
|
||||
WHERE ABS(ventes_na + ventes_ue + ventes_jp + ventes_autre - ventes_total) > 0.1;""")
|
||||
|
||||
connection.commit()
|
||||
|
||||
# 7. Création du DataFrame propre
|
||||
return pandas.read_sql("SELECT * FROM plain_jeu;", con=connection)
|
||||
|
||||
|
||||
##########
|
||||
# Partie 2
|
||||
##########
|
||||
|
||||
def sales_graphs(connection):
|
||||
# 1. Calcul des ventes moyennes par année de sortie et pour le genre aventure
|
||||
df = pandas.read_sql("""SELECT annee_sortie, AVG(ventes_total) ventes_moyennes, SUM(ventes_total) ventes_totales FROM plain_jeu
|
||||
WHERE genre = 'Adventure' AND annee_sortie IS NOT NULL
|
||||
GROUP BY annee_sortie
|
||||
ORDER BY annee_sortie;""", con=connection)
|
||||
|
||||
# 2/3. Affichage sous forme de courbe
|
||||
fig = df.plot(x='annee_sortie', y=['ventes_moyennes', 'ventes_totales'])
|
||||
fig.legend(['Ventes moyennes', 'Ventes totales'])
|
||||
fig.set_xlabel('Année de sortie')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
# 4. Ventes totales pour l'ensemble des jeux
|
||||
df = pandas.read_sql("""SELECT annee_sortie, genre, SUM(ventes_total) ventes_totales FROM plain_jeu
|
||||
WHERE annee_sortie IS NOT NULL
|
||||
GROUP BY annee_sortie, genre
|
||||
ORDER BY annee_sortie;""", con=connection)
|
||||
fig, ax = plt.subplots()
|
||||
for label, group in df.groupby(['genre']):
|
||||
ax = group.plot(ax=ax, kind='line', x='annee_sortie', y='ventes_totales', label=label)
|
||||
ax.set_xlabel('Année de sortie')
|
||||
ax.set_ylabel('Ventes (en millions)')
|
||||
|
||||
|
||||
##########
|
||||
# Partie 3
|
||||
##########
|
||||
|
||||
def sales2_graphs(connection):
|
||||
# 1. Calcul du total des ventes en Europe par plateforme
|
||||
df = pandas.read_sql("""SELECT plateforme, SUM(ventes_ue) ventes_ue FROM plain_jeu
|
||||
GROUP BY plateforme
|
||||
ORDER BY ventes_ue;""", con=connection)
|
||||
|
||||
def plot_ventes_ue(df: pandas.DataFrame, plot_kind: str = 'line'):
|
||||
if plot_kind == 'line':
|
||||
fig = df.plot(x='plateforme', y='ventes_ue', legend=False)
|
||||
else:
|
||||
fig = df.plot(x='plateforme', y='ventes_ue', kind=plot_kind)
|
||||
fig.set_xlabel('Plateforme')
|
||||
fig.set_ylabel('Ventes en Europe (en millions)')
|
||||
fig.set_title('Ventes de jeux vidéos en Europe par plateforme')
|
||||
|
||||
# 2. Affichage sous forme de courbe
|
||||
plot_ventes_ue(df)
|
||||
|
||||
# 3. Affichage sous forme d'histogramme (TODO labels)
|
||||
# plot_ventes_ue(df, 'hist')
|
||||
plot_ventes_ue(df, 'bar')
|
||||
|
||||
# 4. Calcul du total des ventes par plateforme et par zone géographique
|
||||
df = pandas.read_sql("""SELECT plateforme, SUM(ventes_na) ventes_na, SUM(ventes_ue) ventes_ue, SUM(ventes_jp) ventes_jp, SUM(ventes_autre) ventes_autre FROM plain_jeu
|
||||
GROUP BY plateforme;""", con=connection)
|
||||
|
||||
# 5/6. Affichage sous forme de courbes
|
||||
fig = df.plot(x='plateforme', style=['r*-', 'bo--', 'y^-', 'gs--']) # TODO linestyle
|
||||
fig.set_xlabel('Plateforme')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
fig = df.plot.bar(x='plateforme', y=['ventes_na', 'ventes_ue', 'ventes_jp', 'ventes_autre'])
|
||||
fig.set_xlabel('Plateforme')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
|
||||
cur = connection.cursor()
|
||||
|
||||
|
||||
##########
|
||||
# Partie 4
|
||||
##########
|
||||
|
||||
def plot_ventes_jeu(cur: psycopg2.extensions.cursor, nom: str, pourcentages: bool = True):
|
||||
# 1. Récupération des ventes, réorganisées en plusieurs lignes dans le dataframe
|
||||
cur.execute("""SELECT ventes_na, ventes_ue, ventes_jp, ventes_autre FROM plain_jeu
|
||||
WHERE nom = '%s';""" % nom)
|
||||
data = cur.fetchone()
|
||||
zones = [desc[0].split('_')[1] for desc in cur.description]
|
||||
df = pandas.DataFrame([[zones[i], float(data[i])] for i in range(len(data))], columns=['zone', 'ventes'],
|
||||
index=zones)
|
||||
|
||||
title = 'Ventes du jeu ' + nom + ' par zone géographique'
|
||||
|
||||
# 2. Diagramme en bâtons
|
||||
fig = df.plot.bar(x='zone', y='ventes', legend=False, rot=0)
|
||||
fig.set_title(title)
|
||||
|
||||
if pourcentages:
|
||||
# 4. Diagramme camembert avec pourcentages
|
||||
fig = df.plot.pie(y='ventes', labels=None, autopct='%1.1f%%')
|
||||
else:
|
||||
# 3. Diagramme camembert
|
||||
fig = df.plot.pie(y='ventes', legend=False)
|
||||
fig.set_title(title)
|
||||
fig.set_ylabel('Zone géographique')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
|
||||
plot_ventes_jeu(cur, 'Mario Kart 64')
|
||||
|
||||
# 5. Résultats de Mario Kart Wii
|
||||
plot_ventes_jeu(cur, 'Mario Kart Wii')
|
||||
|
||||
# Partie 5
|
||||
|
||||
# 1/2. Pourcentage du total des ventes par genre
|
||||
df = pandas.read_sql("""SELECT genre, SUM(ventes_total) total_ventes FROM plain_jeu
|
||||
GROUP BY genre;""", con=connection)
|
||||
df.set_index('genre', inplace=True)
|
||||
|
||||
# 3. Diagramme camembert
|
||||
fig = df.plot.pie(y='total_ventes', legend=False, autopct='%1.1f%%')
|
||||
fig.set_title('Ventes mondiales de jeux vidéos par genre')
|
||||
fig.set_ylabel('')
|
||||
|
||||
# 4. 4 camemberts du total des ventes par genre et par
|
||||
df = pandas.read_sql("""
|
||||
SELECT CASE WHEN annee_sortie < 1990 THEN '< 1990'
|
||||
WHEN annee_sortie BETWEEN 1990 AND 1999 THEN '<=> 1990-1999'
|
||||
WHEN annee_sortie BETWEEN 2000 AND 2009 THEN '<=> 2000-2009'
|
||||
WHEN annee_sortie >= 2010 THEN '>= 2010'
|
||||
END annee,
|
||||
genre,
|
||||
SUM(ventes_total) ventes_totales
|
||||
FROM plain_jeu
|
||||
WHERE annee_sortie IS NOT NULL
|
||||
GROUP BY annee, genre
|
||||
ORDER BY annee, genre;""", con=connection)
|
||||
grouped = df.groupby('annee')
|
||||
rowlength = grouped.ngroups // 2
|
||||
fig, axs = plt.subplots(figsize=(9, 4), nrows=2, ncols=rowlength)
|
||||
targets = zip(grouped.groups.keys(), axs.flatten())
|
||||
legend = []
|
||||
|
||||
for i, (key, ax) in enumerate(targets):
|
||||
group = grouped.get_group(key)
|
||||
legend = group['genre']
|
||||
ax = group.plot.pie(ax=ax, y='ventes_totales', labels=None, legend=False, colors=plt.cm.tab20.colors)
|
||||
ax.set_ylabel('')
|
||||
ax.set_title(key)
|
||||
fig.legend(legend)
|
||||
fig.suptitle('Ventes de jeux vidéos par genre et par période')
|
||||
|
||||
plt.show()
|
||||
cur.close()
|
||||
|
||||
connection.close()
|
@ -0,0 +1,9 @@
|
||||
\i tables.sql
|
||||
\i pays.sql
|
||||
\i discipline.sql
|
||||
\i athletes.sql
|
||||
\i pratiquer.sql
|
||||
\i epreuve.sql
|
||||
\i resultats.sql
|
||||
|
||||
\d
|
@ -0,0 +1,208 @@
|
||||
INSERT INTO Pays VALUES('NOR','Norway');
|
||||
INSERT INTO Pays VALUES('ESP','Spain');
|
||||
INSERT INTO Pays VALUES('ITA','Italy');
|
||||
INSERT INTO Pays VALUES('FRA','France');
|
||||
INSERT INTO Pays VALUES('CHI','Chile');
|
||||
INSERT INTO Pays VALUES('SUD','Sudan');
|
||||
INSERT INTO Pays VALUES('IRI','Islamic Republic of Iran');
|
||||
INSERT INTO Pays VALUES('AZE','Azerbaijan');
|
||||
INSERT INTO Pays VALUES('NED','Netherlands');
|
||||
INSERT INTO Pays VALUES('AUS','Australia');
|
||||
INSERT INTO Pays VALUES('USA','United States of America');
|
||||
INSERT INTO Pays VALUES('QAT','Qatar');
|
||||
INSERT INTO Pays VALUES('EGY','Egypt');
|
||||
INSERT INTO Pays VALUES('BEL','Belgium');
|
||||
INSERT INTO Pays VALUES('MAS','Malaysia');
|
||||
INSERT INTO Pays VALUES('SGP','Singapore');
|
||||
INSERT INTO Pays VALUES('MDV','Maldives');
|
||||
INSERT INTO Pays VALUES('KSA','Saudi Arabia');
|
||||
INSERT INTO Pays VALUES('GER','Germany');
|
||||
INSERT INTO Pays VALUES('UZB','Uzbekistan');
|
||||
INSERT INTO Pays VALUES('INA','Indonesia');
|
||||
INSERT INTO Pays VALUES('KAZ','Kazakhstan');
|
||||
INSERT INTO Pays VALUES('BRN','Bahrain');
|
||||
INSERT INTO Pays VALUES('JPN','Japan');
|
||||
INSERT INTO Pays VALUES('ETH','Ethiopia');
|
||||
INSERT INTO Pays VALUES('CAN','Canada');
|
||||
INSERT INTO Pays VALUES('MLT','Malta');
|
||||
INSERT INTO Pays VALUES('SRI','Sri Lanka');
|
||||
INSERT INTO Pays VALUES('MAR','Morocco');
|
||||
INSERT INTO Pays VALUES('AUT','Austria');
|
||||
INSERT INTO Pays VALUES('MTN','Mauritania');
|
||||
INSERT INTO Pays VALUES('ROC','ROC');
|
||||
INSERT INTO Pays VALUES('BRA','Brazil');
|
||||
INSERT INTO Pays VALUES('LBA','Libya');
|
||||
INSERT INTO Pays VALUES('NRU','Nauru');
|
||||
INSERT INTO Pays VALUES('SUI','Switzerland');
|
||||
INSERT INTO Pays VALUES('RSA','South Africa');
|
||||
INSERT INTO Pays VALUES('GUY','Guyana');
|
||||
INSERT INTO Pays VALUES('GEO','Georgia');
|
||||
INSERT INTO Pays VALUES('POR','Portugal');
|
||||
INSERT INTO Pays VALUES('JOR','Jordan');
|
||||
INSERT INTO Pays VALUES('PLE','Palestine');
|
||||
INSERT INTO Pays VALUES('IND','India');
|
||||
INSERT INTO Pays VALUES('CYP','Cyprus');
|
||||
INSERT INTO Pays VALUES('NGR','Nigeria');
|
||||
INSERT INTO Pays VALUES('TUN','Tunisia');
|
||||
INSERT INTO Pays VALUES('SRB','Serbia');
|
||||
INSERT INTO Pays VALUES('MEX','Mexico');
|
||||
INSERT INTO Pays VALUES('COL','Colombia');
|
||||
INSERT INTO Pays VALUES('ESA','El Salvador');
|
||||
INSERT INTO Pays VALUES('ROU','Romania');
|
||||
INSERT INTO Pays VALUES('POL','Poland');
|
||||
INSERT INTO Pays VALUES('FSM','Federated States of Micronesia');
|
||||
INSERT INTO Pays VALUES('NZL','New Zealand');
|
||||
INSERT INTO Pays VALUES('TUR','Turkey');
|
||||
INSERT INTO Pays VALUES('SWE','Sweden');
|
||||
INSERT INTO Pays VALUES('GBR','Great Britain');
|
||||
INSERT INTO Pays VALUES('HUN','Hungary');
|
||||
INSERT INTO Pays VALUES('LTU','Lithuania');
|
||||
INSERT INTO Pays VALUES('PUR','Puerto Rico');
|
||||
INSERT INTO Pays VALUES('ANG','Angola');
|
||||
INSERT INTO Pays VALUES('CGO','Congo');
|
||||
INSERT INTO Pays VALUES('MON','Monaco');
|
||||
INSERT INTO Pays VALUES('RWA','Rwanda');
|
||||
INSERT INTO Pays VALUES('KEN','Kenya');
|
||||
INSERT INTO Pays VALUES('ARM','Armenia');
|
||||
INSERT INTO Pays VALUES('SAM','Samoa (until 1996 Western Samoa)');
|
||||
INSERT INTO Pays VALUES('BRU','Brunei Darussalam');
|
||||
INSERT INTO Pays VALUES('BAN','Bangladesh');
|
||||
INSERT INTO Pays VALUES('KOR','Republic of Korea');
|
||||
INSERT INTO Pays VALUES('BEN','Benin');
|
||||
INSERT INTO Pays VALUES('CIV','Côte d''Ivoire');
|
||||
INSERT INTO Pays VALUES('TTO','Trinidad and Tobago');
|
||||
INSERT INTO Pays VALUES('CHN','People''s Republic of China');
|
||||
INSERT INTO Pays VALUES('SEN','Senegal');
|
||||
INSERT INTO Pays VALUES('ALG','Algeria');
|
||||
INSERT INTO Pays VALUES('TJK','Tajikistan');
|
||||
INSERT INTO Pays VALUES('PAK','Pakistan');
|
||||
INSERT INTO Pays VALUES('KGZ','Kyrgyzstan');
|
||||
INSERT INTO Pays VALUES('LAT','Latvia');
|
||||
INSERT INTO Pays VALUES('OMA','Oman');
|
||||
INSERT INTO Pays VALUES('KUW','Kuwait');
|
||||
INSERT INTO Pays VALUES('IRQ','Iraq');
|
||||
INSERT INTO Pays VALUES('EOR','EOR');
|
||||
INSERT INTO Pays VALUES('YEM','Yemen');
|
||||
INSERT INTO Pays VALUES('ISR','Israel');
|
||||
INSERT INTO Pays VALUES('CUB','Cuba');
|
||||
INSERT INTO Pays VALUES('ARG','Argentina');
|
||||
INSERT INTO Pays VALUES('UKR','Ukraine');
|
||||
INSERT INTO Pays VALUES('UAE','United Arab Emirates');
|
||||
INSERT INTO Pays VALUES('NIG','Niger');
|
||||
INSERT INTO Pays VALUES('DJI','Djibouti');
|
||||
INSERT INTO Pays VALUES('SOM','Somalia');
|
||||
INSERT INTO Pays VALUES('BUL','Bulgaria');
|
||||
INSERT INTO Pays VALUES('BER','Bermuda');
|
||||
INSERT INTO Pays VALUES('IRL','Ireland');
|
||||
INSERT INTO Pays VALUES('JAM','Jamaica');
|
||||
INSERT INTO Pays VALUES('EST','Estonia');
|
||||
INSERT INTO Pays VALUES('PAR','Paraguay');
|
||||
INSERT INTO Pays VALUES('CRC','Costa Rica');
|
||||
INSERT INTO Pays VALUES('DOM','Dominican Republic');
|
||||
INSERT INTO Pays VALUES('HON','Honduras');
|
||||
INSERT INTO Pays VALUES('CPV','Cape Verde');
|
||||
INSERT INTO Pays VALUES('GRE','Greece');
|
||||
INSERT INTO Pays VALUES('VEN','Venezuela');
|
||||
INSERT INTO Pays VALUES('UGA','Uganda');
|
||||
INSERT INTO Pays VALUES('PER','Peru');
|
||||
INSERT INTO Pays VALUES('BLR','Belarus');
|
||||
INSERT INTO Pays VALUES('SMR','San Marino');
|
||||
INSERT INTO Pays VALUES('GHA','Ghana');
|
||||
INSERT INTO Pays VALUES('ECU','Ecuador');
|
||||
INSERT INTO Pays VALUES('BOT','Botswana');
|
||||
INSERT INTO Pays VALUES('BAH','Bahamas');
|
||||
INSERT INTO Pays VALUES('DEN','Denmark');
|
||||
INSERT INTO Pays VALUES('PHI','Philippines');
|
||||
INSERT INTO Pays VALUES('GUM','Guam');
|
||||
INSERT INTO Pays VALUES('MAD','Madagascar');
|
||||
INSERT INTO Pays VALUES('HAI','Haiti');
|
||||
INSERT INTO Pays VALUES('CZE','Czech Republic');
|
||||
INSERT INTO Pays VALUES('MNE','Montenegro');
|
||||
INSERT INTO Pays VALUES('AFG','Afghanistan');
|
||||
INSERT INTO Pays VALUES('URU','Uruguay');
|
||||
INSERT INTO Pays VALUES('PAN','Panama');
|
||||
INSERT INTO Pays VALUES('FIN','Finland');
|
||||
INSERT INTO Pays VALUES('CMR','Cameroon');
|
||||
INSERT INTO Pays VALUES('SYR','Syrian Arab Republic');
|
||||
INSERT INTO Pays VALUES('TKM','Turkmenistan');
|
||||
INSERT INTO Pays VALUES('HKG','Hong Kong, China');
|
||||
INSERT INTO Pays VALUES('TOG','Togo');
|
||||
INSERT INTO Pays VALUES('SEY','Seychelles');
|
||||
INSERT INTO Pays VALUES('MGL','Mongolia');
|
||||
INSERT INTO Pays VALUES('SLO','Slovenia');
|
||||
INSERT INTO Pays VALUES('GUI','Guinea');
|
||||
INSERT INTO Pays VALUES('SVK','Slovakia');
|
||||
INSERT INTO Pays VALUES('FIJ','Fiji');
|
||||
INSERT INTO Pays VALUES('ZAM','Zambia');
|
||||
INSERT INTO Pays VALUES('NCA','Nicaragua');
|
||||
INSERT INTO Pays VALUES('SLE','Sierra Leone');
|
||||
INSERT INTO Pays VALUES('GUA','Guatemala');
|
||||
INSERT INTO Pays VALUES('PNG','Papua New Guinea');
|
||||
INSERT INTO Pays VALUES('GAM','Gambia');
|
||||
INSERT INTO Pays VALUES('LBN','LBN');
|
||||
INSERT INTO Pays VALUES('COK','Cook Islands');
|
||||
INSERT INTO Pays VALUES('BAR','Barbados');
|
||||
INSERT INTO Pays VALUES('LUX','Luxembourg');
|
||||
INSERT INTO Pays VALUES('MDA','Republic of Moldova');
|
||||
INSERT INTO Pays VALUES('NEP','Nepal');
|
||||
INSERT INTO Pays VALUES('CRO','Croatia');
|
||||
INSERT INTO Pays VALUES('KIR','Kiribati');
|
||||
INSERT INTO Pays VALUES('MKD','North Macedonia');
|
||||
INSERT INTO Pays VALUES('MAW','Malawi');
|
||||
INSERT INTO Pays VALUES('COD','Democratic Republic of the Congo');
|
||||
INSERT INTO Pays VALUES('LAO','Lao People''s Democratic Republic');
|
||||
INSERT INTO Pays VALUES('THA','Thailand');
|
||||
INSERT INTO Pays VALUES('VIN','St Vincent and the Grenadines');
|
||||
INSERT INTO Pays VALUES('ALB','Albania');
|
||||
INSERT INTO Pays VALUES('GBS','Guinea-Bissau');
|
||||
INSERT INTO Pays VALUES('BOL','Bolivia');
|
||||
INSERT INTO Pays VALUES('BIH','Bosnia and Herzegovina');
|
||||
INSERT INTO Pays VALUES('TPE','Chinese Taipei');
|
||||
INSERT INTO Pays VALUES('LCA','Saint Lucia');
|
||||
INSERT INTO Pays VALUES('PLW','Palau');
|
||||
INSERT INTO Pays VALUES('MRI','Mauritius');
|
||||
INSERT INTO Pays VALUES('SKN','Saint Kitts and Nevis');
|
||||
INSERT INTO Pays VALUES('CAY','Cayman Islands');
|
||||
INSERT INTO Pays VALUES('ASA','American Samoa');
|
||||
INSERT INTO Pays VALUES('BIZ','Belize');
|
||||
INSERT INTO Pays VALUES('VAN','Vanuatu');
|
||||
INSERT INTO Pays VALUES('STP','Sao Tome and Principe');
|
||||
INSERT INTO Pays VALUES('TLS','Timor-Leste');
|
||||
INSERT INTO Pays VALUES('ISV','Virgin Islands, US');
|
||||
INSERT INTO Pays VALUES('ERI','Eritrea');
|
||||
INSERT INTO Pays VALUES('MLI','Mali');
|
||||
INSERT INTO Pays VALUES('BUR','Burkina Faso');
|
||||
INSERT INTO Pays VALUES('TGA','Tonga');
|
||||
INSERT INTO Pays VALUES('NAM','Namibia');
|
||||
INSERT INTO Pays VALUES('VIE','Vietnam');
|
||||
INSERT INTO Pays VALUES('SWZ','Eswatini');
|
||||
INSERT INTO Pays VALUES('AND','Andorra');
|
||||
INSERT INTO Pays VALUES('ARU','Aruba');
|
||||
INSERT INTO Pays VALUES('COM','Comoros');
|
||||
INSERT INTO Pays VALUES('GEQ','Equatorial Guinea');
|
||||
INSERT INTO Pays VALUES('LBR','Liberia');
|
||||
INSERT INTO Pays VALUES('GRN','Grenada');
|
||||
INSERT INTO Pays VALUES('SOL','Solomon Islands');
|
||||
INSERT INTO Pays VALUES('MHL','Marshall Islands');
|
||||
INSERT INTO Pays VALUES('BDI','Burundi');
|
||||
INSERT INTO Pays VALUES('TAN','United Republic of Tanzania');
|
||||
INSERT INTO Pays VALUES('GAB','Gabon');
|
||||
INSERT INTO Pays VALUES('KOS','Kosovo');
|
||||
INSERT INTO Pays VALUES('ANT','Antigua and Barbuda');
|
||||
INSERT INTO Pays VALUES('MOZ','Mozambique');
|
||||
INSERT INTO Pays VALUES('ISL','Iceland');
|
||||
INSERT INTO Pays VALUES('SSD','South Sudan');
|
||||
INSERT INTO Pays VALUES('LIE','Liechtenstein');
|
||||
INSERT INTO Pays VALUES('CAM','Cambodia');
|
||||
INSERT INTO Pays VALUES('CHA','Chad');
|
||||
INSERT INTO Pays VALUES('BHU','Bhutan');
|
||||
INSERT INTO Pays VALUES('ZIM','Zimbabwe');
|
||||
INSERT INTO Pays VALUES('LES','Lesotho');
|
||||
INSERT INTO Pays VALUES('DMA','Dominique');
|
||||
INSERT INTO Pays VALUES('TUV','Tuvalu');
|
||||
INSERT INTO Pays VALUES('IVB','Virgin Islands, British');
|
||||
INSERT INTO Pays VALUES('CAF','Central African Republic');
|
||||
INSERT INTO Pays VALUES('MYA','Myanmar');
|
||||
INSERT INTO Pays VALUES('SUR','Suriname');
|
||||
INSERT INTO Pays VALUES('RUS','Russian Federation');
|
||||
INSERT INTO Pays VALUES('URS','URSS');
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@
|
||||
DROP TABLE IF EXISTS Present;
|
||||
DROP TABLE IF EXISTS Resultat_FR;
|
||||
DROP TABLE IF EXISTS Resultat;
|
||||
DROP TABLE IF EXISTS Medaille;
|
||||
DROP TABLE IF EXISTS Epreuve;
|
||||
DROP TABLE IF EXISTS Pratiquer;
|
||||
DROP TABLE IF EXISTS Athlete;
|
||||
DROP TABLE IF EXISTS Discipline;
|
||||
DROP TABLE IF EXISTS Pays;
|
||||
|
||||
CREATE TABLE Pays(
|
||||
code char(3) PRIMARY KEY,
|
||||
nom varchar(40) UNIQUE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE Discipline(
|
||||
code char(3) PRIMARY KEY,
|
||||
nom varchar(40) UNIQUE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE Athlete(
|
||||
code char(6) PRIMARY KEY,
|
||||
nom varchar(40) NOT NULL,
|
||||
prenom varchar(40) NOT NULL,
|
||||
sexe char(1) CHECK(sexe IN('F','M')),
|
||||
dateNaiss date,
|
||||
paysNaiss char(3) REFERENCES Pays,
|
||||
pays char(3) NOT NULL REFERENCES Pays,
|
||||
taille numeric(3,2)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE Pratiquer(
|
||||
athlete char(6) REFERENCES Athlete,
|
||||
discipl char(3) REFERENCES Discipline,
|
||||
PRIMARY KEY(athlete, discipl)
|
||||
);
|
||||
|
||||
CREATE TABLE Epreuve(
|
||||
code char(4) PRIMARY KEY,
|
||||
discipl char(3) NOT NULL REFERENCES Discipline,
|
||||
nom varchar(55) NOT NULL,
|
||||
dateE date NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE Medaille(
|
||||
place numeric(1) PRIMARY KEY,
|
||||
couleur varchar(6)
|
||||
);
|
||||
|
||||
CREATE TABLE Resultat(
|
||||
epreuve char(4) REFERENCES Epreuve,
|
||||
athlete char(6) REFERENCES Athlete,
|
||||
medaille numeric(1) REFERENCES Medaille,
|
||||
PRIMARY KEY(epreuve,athlete)
|
||||
);
|
||||
|
||||
INSERT INTO Medaille VALUES(1,'Or');
|
||||
INSERT INTO Medaille VALUES(2,'Argent');
|
||||
INSERT INTO Medaille VALUES(3,'Bronze');
|
||||
|
||||
|
||||
/*
|
||||
disciplrel2, 0N Discipline, 11 Epreuve:
|
||||
Discipline: code, nom
|
||||
Pratiquer, 0N Athlete, 0N Discipline:
|
||||
:
|
||||
|
||||
Epreuve: code, nom, dateE
|
||||
Resultat, 0N Athlete, 0N Epreuve, 0N Medaille:
|
||||
Athlete: code, nom, prenom, sexe, dateNaiss, taille
|
||||
Resider, 0N Pays, 11 Athlete:
|
||||
|
||||
:
|
||||
Medaille: place, couleur
|
||||
Etre né, 0N Pays, 01 Athlete:
|
||||
Pays: code, nom
|
||||
*/
|
|
@ -0,0 +1,4 @@
|
||||
digraph abc {
|
||||
rankdir=LR;
|
||||
a -> b -> c;
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,172 @@
|
||||
{
|
||||
"AED": "United Arab Emirates Dirham",
|
||||
"AFN": "Afghan Afghani",
|
||||
"ALL": "Albanian Lek",
|
||||
"AMD": "Armenian Dram",
|
||||
"ANG": "Netherlands Antillean Guilder",
|
||||
"AOA": "Angolan Kwanza",
|
||||
"ARS": "Argentine Peso",
|
||||
"AUD": "Australian Dollar",
|
||||
"AWG": "Aruban Florin",
|
||||
"AZN": "Azerbaijani Manat",
|
||||
"BAM": "Bosnia-Herzegovina Convertible Mark",
|
||||
"BBD": "Barbadian Dollar",
|
||||
"BDT": "Bangladeshi Taka",
|
||||
"BGN": "Bulgarian Lev",
|
||||
"BHD": "Bahraini Dinar",
|
||||
"BIF": "Burundian Franc",
|
||||
"BMD": "Bermudan Dollar",
|
||||
"BND": "Brunei Dollar",
|
||||
"BOB": "Bolivian Boliviano",
|
||||
"BRL": "Brazilian Real",
|
||||
"BSD": "Bahamian Dollar",
|
||||
"BTC": "Bitcoin",
|
||||
"BTN": "Bhutanese Ngultrum",
|
||||
"BWP": "Botswanan Pula",
|
||||
"BYN": "Belarusian Ruble",
|
||||
"BZD": "Belize Dollar",
|
||||
"CAD": "Canadian Dollar",
|
||||
"CDF": "Congolese Franc",
|
||||
"CHF": "Swiss Franc",
|
||||
"CLF": "Chilean Unit of Account (UF)",
|
||||
"CLP": "Chilean Peso",
|
||||
"CNH": "Chinese Yuan (Offshore)",
|
||||
"CNY": "Chinese Yuan",
|
||||
"COP": "Colombian Peso",
|
||||
"CRC": "Costa Rican Colón",
|
||||
"CUC": "Cuban Convertible Peso",
|
||||
"CUP": "Cuban Peso",
|
||||
"CVE": "Cape Verdean Escudo",
|
||||
"CZK": "Czech Republic Koruna",
|
||||
"DJF": "Djiboutian Franc",
|
||||
"DKK": "Danish Krone",
|
||||
"DOP": "Dominican Peso",
|
||||
"DZD": "Algerian Dinar",
|
||||
"EGP": "Egyptian Pound",
|
||||
"ERN": "Eritrean Nakfa",
|
||||
"ETB": "Ethiopian Birr",
|
||||
"EUR": "Euro",
|
||||
"FJD": "Fijian Dollar",
|
||||
"FKP": "Falkland Islands Pound",
|
||||
"GBP": "British Pound Sterling",
|
||||
"GEL": "Georgian Lari",
|
||||
"GGP": "Guernsey Pound",
|
||||
"GHS": "Ghanaian Cedi",
|
||||
"GIP": "Gibraltar Pound",
|
||||
"GMD": "Gambian Dalasi",
|
||||
"GNF": "Guinean Franc",
|
||||
"GTQ": "Guatemalan Quetzal",
|
||||
"GYD": "Guyanaese Dollar",
|
||||
"HKD": "Hong Kong Dollar",
|
||||
"HNL": "Honduran Lempira",
|
||||
"HRK": "Croatian Kuna",
|
||||
"HTG": "Haitian Gourde",
|
||||
"HUF": "Hungarian Forint",
|
||||
"IDR": "Indonesian Rupiah",
|
||||
"ILS": "Israeli New Sheqel",
|
||||
"IMP": "Manx pound",
|
||||
"INR": "Indian Rupee",
|
||||
"IQD": "Iraqi Dinar",
|
||||
"IRR": "Iranian Rial",
|
||||
"ISK": "Icelandic Króna",
|
||||
"JEP": "Jersey Pound",
|
||||
"JMD": "Jamaican Dollar",
|
||||
"JOD": "Jordanian Dinar",
|
||||
"JPY": "Japanese Yen",
|
||||
"KES": "Kenyan Shilling",
|
||||
"KGS": "Kyrgystani Som",
|
||||
"KHR": "Cambodian Riel",
|
||||
"KMF": "Comorian Franc",
|
||||
"KPW": "North Korean Won",
|
||||
"KRW": "South Korean Won",
|
||||
"KWD": "Kuwaiti Dinar",
|
||||
"KYD": "Cayman Islands Dollar",
|
||||
"KZT": "Kazakhstani Tenge",
|
||||
"LAK": "Laotian Kip",
|
||||
"LBP": "Lebanese Pound",
|
||||
"LKR": "Sri Lankan Rupee",
|
||||
"LRD": "Liberian Dollar",
|
||||
"LSL": "Lesotho Loti",
|
||||
"LYD": "Libyan Dinar",
|
||||
"MAD": "Moroccan Dirham",
|
||||
"MDL": "Moldovan Leu",
|
||||
"MGA": "Malagasy Ariary",
|
||||
"MKD": "Macedonian Denar",
|
||||
"MMK": "Myanma Kyat",
|
||||
"MNT": "Mongolian Tugrik",
|
||||
"MOP": "Macanese Pataca",
|
||||
"MRU": "Mauritanian Ouguiya",
|
||||
"MUR": "Mauritian Rupee",
|
||||
"MVR": "Maldivian Rufiyaa",
|
||||
"MWK": "Malawian Kwacha",
|
||||
"MXN": "Mexican Peso",
|
||||
"MYR": "Malaysian Ringgit",
|
||||
"MZN": "Mozambican Metical",
|
||||
"NAD": "Namibian Dollar",
|
||||
"NGN": "Nigerian Naira",
|
||||
"NIO": "Nicaraguan Córdoba",
|
||||
"NOK": "Norwegian Krone",
|
||||
"NPR": "Nepalese Rupee",
|
||||
"NZD": "New Zealand Dollar",
|
||||
"OMR": "Omani Rial",
|
||||
"PAB": "Panamanian Balboa",
|
||||
"PEN": "Peruvian Nuevo Sol",
|
||||
"PGK": "Papua New Guinean Kina",
|
||||
"PHP": "Philippine Peso",
|
||||
"PKR": "Pakistani Rupee",
|
||||
"PLN": "Polish Zloty",
|
||||
"PYG": "Paraguayan Guarani",
|
||||
"QAR": "Qatari Rial",
|
||||
"RON": "Romanian Leu",
|
||||
"RSD": "Serbian Dinar",
|
||||
"RUB": "Russian Ruble",
|
||||
"RWF": "Rwandan Franc",
|
||||
"SAR": "Saudi Riyal",
|
||||
"SBD": "Solomon Islands Dollar",
|
||||
"SCR": "Seychellois Rupee",
|
||||
"SDG": "Sudanese Pound",
|
||||
"SEK": "Swedish Krona",
|
||||
"SGD": "Singapore Dollar",
|
||||
"SHP": "Saint Helena Pound",
|
||||
"SLL": "Sierra Leonean Leone",
|
||||
"SOS": "Somali Shilling",
|
||||
"SRD": "Surinamese Dollar",
|
||||
"SSP": "South Sudanese Pound",
|
||||
"STD": "São Tomé and Príncipe Dobra (pre-2018)",
|
||||
"STN": "São Tomé and Príncipe Dobra",
|
||||
"SVC": "Salvadoran Colón",
|
||||
"SYP": "Syrian Pound",
|
||||
"SZL": "Swazi Lilangeni",
|
||||
"THB": "Thai Baht",
|
||||
"TJS": "Tajikistani Somoni",
|
||||
"TMT": "Turkmenistani Manat",
|
||||
"TND": "Tunisian Dinar",
|
||||
"TOP": "Tongan Pa'anga",
|
||||
"TRY": "Turkish Lira",
|
||||
"TTD": "Trinidad and Tobago Dollar",
|
||||
"TWD": "New Taiwan Dollar",
|
||||
"TZS": "Tanzanian Shilling",
|
||||
"UAH": "Ukrainian Hryvnia",
|
||||
"UGX": "Ugandan Shilling",
|
||||
"USD": "United States Dollar",
|
||||
"UYU": "Uruguayan Peso",
|
||||
"UZS": "Uzbekistan Som",
|
||||
"VEF": "Venezuelan Bolívar Fuerte (Old)",
|
||||
"VES": "Venezuelan Bolívar Soberano",
|
||||
"VND": "Vietnamese Dong",
|
||||
"VUV": "Vanuatu Vatu",
|
||||
"WST": "Samoan Tala",
|
||||
"XAF": "CFA Franc BEAC",
|
||||
"XAG": "Silver Ounce",
|
||||
"XAU": "Gold Ounce",
|
||||
"XCD": "East Caribbean Dollar",
|
||||
"XDR": "Special Drawing Rights",
|
||||
"XOF": "CFA Franc BCEAO",
|
||||
"XPD": "Palladium Ounce",
|
||||
"XPF": "CFP Franc",
|
||||
"XPT": "Platinum Ounce",
|
||||
"YER": "Yemeni Rial",
|
||||
"ZAR": "South African Rand",
|
||||
"ZMW": "Zambian Kwacha",
|
||||
"ZWL": "Zimbabwean Dollar"
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
sed -r 's/: psycopg2\.(connection|cursor)//' load.py > /tmp/patched_load.py
|
||||
python3 /tmp/patched_load.py
|
@ -0,0 +1,171 @@
|
||||
import pandas
|
||||
import psycopg2 # pip3 install types-psycopg2
|
||||
import matplotlib.pyplot as plt
|
||||
from getpass import getpass
|
||||
import json
|
||||
import folium
|
||||
from folium.plugins import BeautifyIcon
|
||||
from typing import Union
|
||||
|
||||
def create_tables(connection: psycopg2.connection, filename: str):
|
||||
cur = connection.cursor()
|
||||
with open(filename) as f:
|
||||
cur.execute(f.read())
|
||||
connection.commit()
|
||||
cur.close()
|
||||
|
||||
def load_currencies(connection: psycopg2.connection, filename: str):
|
||||
cur = connection.cursor()
|
||||
with open(filename) as f:
|
||||
for iso, full_name in json.load(f).items():
|
||||
cur.execute("INSERT INTO currency VALUES (%s, %s);", (iso, full_name))
|
||||
connection.commit()
|
||||
cur.close()
|
||||
|
||||
def format_price(price: Union[float, str]) -> float:
|
||||
if isinstance(price, float):
|
||||
return price
|
||||
return float(price.replace(',', ''))
|
||||
|
||||
def format_award(award: str) -> int:
|
||||
if award == '3 MICHELIN Stars':
|
||||
return 3
|
||||
if award == '2 MICHELIN Stars':
|
||||
return 2
|
||||
if award == '1 MICHELIN Star':
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def color_award(stars: int) -> str:
|
||||
if stars == 3:
|
||||
return 'orange'
|
||||
if stars == 2:
|
||||
return '#c0c0c0'
|
||||
if stars == 1:
|
||||
return '#c49c48'
|
||||
return '#132b5e'
|
||||
|
||||
def stars_radius(stars: int) -> int:
|
||||
if stars > 1:
|
||||
return 5
|
||||
if stars == 1:
|
||||
return 4
|
||||
return 3
|
||||
|
||||
def load_restaurants(connection: psycopg2.connection, filename: str):
|
||||
cur = connection.cursor()
|
||||
|
||||
df = pandas.DataFrame(pandas.read_csv(filename))
|
||||
|
||||
for row in df.itertuples():
|
||||
cur.execute("INSERT INTO restaurant (name, location, min_price, max_price, currency, latitude, longitude, phone_number, url, website_url, stars) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id;",
|
||||
(row.Name, row.Location, format_price(row.MinPrice), format_price(row.MaxPrice), row.Currency if not pandas.isnull(row.Currency) else None, row.Latitude, row.Longitude, row.PhoneNumber, row.Url, row.WebsiteUrl, format_award(row.Award))
|
||||
)
|
||||
restaurant_id = cur.fetchone()[0]
|
||||
for cuisine in row.Cuisine.split(', '):
|
||||
#cur.execute("INSERT INTO cuisine (name) VALUES (%s) ON CONFLICT DO NOTHING RETURNING id;", (cuisine,))
|
||||
cur.execute("INSERT INTO cuisine (name) VALUES (%s) ON CONFLICT (name) DO UPDATE SET name = EXCLUDED.name RETURNING id;", (cuisine,))
|
||||
cuisine_id = cur.fetchone()[0]
|
||||
cur.execute("INSERT INTO cuisine_restaurant VALUES (%s, %s);", (restaurant_id, cuisine_id))
|
||||
|
||||
connection.commit()
|
||||
cur.close()
|
||||
|
||||
def cuisine(connection: psycopg2.connection):
|
||||
df = pandas.read_sql("""SELECT c.name, COUNT(*) restaurants
|
||||
FROM cuisine_restaurant cr
|
||||
INNER JOIN cuisine c ON c.id = cr.cuisine
|
||||
GROUP BY c.id
|
||||
ORDER BY 2 DESC
|
||||
LIMIT 20;""", con=connection)
|
||||
|
||||
fig = df.plot.barh(x='name', y='restaurants', legend=False)
|
||||
fig.invert_yaxis()
|
||||
fig.set_title('Most common cuisine types in the Michelin guide')
|
||||
fig.set_xlabel('Cuisine type')
|
||||
fig.set_ylabel('Number of restaurants')
|
||||
fig.bar_label(fig.containers[0]) # Show values
|
||||
|
||||
def currencies(connection: psycopg2.connection):
|
||||
df = pandas.read_sql("""SELECT c.iso, c.full_name, COUNT(*) restaurants
|
||||
FROM restaurant r
|
||||
INNER JOIN currency c ON c.iso = r.currency
|
||||
GROUP BY c.iso
|
||||
ORDER BY 3 DESC
|
||||
LIMIT 10;""", con=connection)
|
||||
|
||||
fig = df.plot.bar(x='iso', y='restaurants', legend=False, rot=0)
|
||||
fig.set_title('Most common accepted currencies in the Michelin guide')
|
||||
fig.set_xlabel('Currency')
|
||||
fig.set_ylabel('Number of restaurants')
|
||||
fig.bar_label(fig.containers[0]) # Show values
|
||||
|
||||
def prices(connection: psycopg2.connection):
|
||||
df = pandas.read_sql("""SELECT CASE WHEN min_price < 10 THEN '< 10'
|
||||
WHEN min_price >= 10 AND min_price < 15 THEN '[10;15['
|
||||
WHEN min_price >= 15 AND min_price < 20 THEN '[15;20['
|
||||
WHEN min_price >= 20 AND min_price < 30 THEN '[20;30['
|
||||
WHEN min_price >= 30 AND min_price < 50 THEN '[30;50['
|
||||
WHEN min_price >= 50 AND min_price < 100 THEN '[50;100['
|
||||
WHEN min_price >= 100 AND min_price < 200 THEN '[100;200['
|
||||
WHEN min_price >= 200 AND min_price < 500 THEN '[200;500['
|
||||
WHEN min_price >= 500 AND min_price < 1000 THEN '[500;1000['
|
||||
WHEN min_price >= 1000 THEN '>= 1000'
|
||||
END min_price_range,
|
||||
COUNT(*) nb
|
||||
FROM restaurant
|
||||
WHERE currency = 'EUR'
|
||||
GROUP BY min_price_range;""", con=connection)
|
||||
|
||||
fig = df.plot.pie(y='nb', labels=df['min_price_range'], legend=False)
|
||||
|
||||
def map(connection: psycopg2.connection):
|
||||
map_osm = folium.Map(zoom_start=4)
|
||||
groups = [folium.FeatureGroup('Bib Gourmand' if stars == 0 else str(stars) + ' stars') for stars in range(4)]
|
||||
df = pandas.read_sql("""SELECT latitude, longitude, name, min_price, max_price, currency, stars FROM restaurant;""", con=connection)
|
||||
#df['color'] = df.apply(color_award, axis=1)
|
||||
for _, latitude, longitude, name, min_price, max_price, currency, stars in df[['latitude', 'longitude', 'name', 'min_price', 'max_price', 'currency', 'stars']].itertuples():
|
||||
is_star = stars != 0
|
||||
popup = (
|
||||
"<strong>{name}</strong><br>"
|
||||
"From {min_price} to {max_price} {currency}<br>"
|
||||
"{award}<br>"
|
||||
"______________________"
|
||||
).format(name=name, min_price=min_price, max_price=max_price, currency=currency, award=str(stars) + ' stars' if is_star else 'Bib Gourmand')
|
||||
color = color_award(stars)
|
||||
if stars == 3:
|
||||
icon = BeautifyIcon(icon='star', inner_icon_style=('color:' + color), border_color='transparent', background_color='transparent')
|
||||
folium.Marker(location=[latitude, longitude], popup=popup, radius=stars_radius(stars), fill=True, fill_opacity=1, icon=icon).add_to(groups[stars])
|
||||
else:
|
||||
folium.CircleMarker(location=[latitude, longitude], popup=popup, color=color, fill_color=color, radius=stars_radius(stars), fill=True, fill_opacity=1).add_to(groups[stars])
|
||||
for group in groups:
|
||||
map_osm.add_child(group)
|
||||
map_osm.add_child(folium.map.LayerControl())
|
||||
map_osm.save('/tmp/test_map.html')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
db_host = input('Nom d\'hôte : ')
|
||||
if not db_host:
|
||||
db_host = 'berlin'
|
||||
db_name = input('Nom de la base de données : ')
|
||||
if not db_name:
|
||||
db_name = 'dbclfreville2'
|
||||
db_user = input('Utilisateur : ')
|
||||
if not db_user:
|
||||
db_user = 'clfreville2'
|
||||
db_password = getpass('Mot de passe : ')
|
||||
|
||||
connection = psycopg2.connect(host=db_host, port=5432, database=db_name, user=db_user, password=db_password)
|
||||
|
||||
#create_tables(connection, 'table.sql')
|
||||
#load_currencies(connection, 'currencies.json')
|
||||
#load_restaurants(connection, 'michelin_my_maps.csv')
|
||||
cuisine(connection)
|
||||
currencies(connection)
|
||||
prices(connection)
|
||||
#map(connection)
|
||||
|
||||
connection.close()
|
||||
|
||||
plt.show()
|
@ -0,0 +1,84 @@
|
||||
import pandas
|
||||
import psycopg2 # pip3 install types-psycopg2
|
||||
import matplotlib.pyplot as plt
|
||||
from getpass import getpass
|
||||
from calendar import month_abbr
|
||||
from typing import Dict
|
||||
|
||||
# Create a mapping
|
||||
# month name to int value
|
||||
month_to_int: Dict[str, int] = dict((val, name) for name, val in enumerate(month_abbr))
|
||||
|
||||
def create_table(connection: psycopg2.connection, filename: str):
|
||||
cur = connection.cursor()
|
||||
|
||||
cur.execute("""CREATE TABLE IF NOT EXISTS unemployment (
|
||||
year_month DATE PRIMARY KEY,
|
||||
primary_school NUMERIC(4, 2) NOT NULL CHECK (primary_school >= 0),
|
||||
high_school NUMERIC(4, 2) NOT NULL CHECK (high_school >= 0),
|
||||
associates_degree NUMERIC(4, 2) NOT NULL CHECK (associates_degree >= 0),
|
||||
professional_degree NUMERIC(4, 2) NOT NULL CHECK (professional_degree >= 0),
|
||||
white NUMERIC(4, 2) NOT NULL CHECK (white >= 0),
|
||||
black NUMERIC(4, 2) NOT NULL CHECK (black >= 0),
|
||||
asian NUMERIC(4, 2) NOT NULL CHECK (asian >= 0),
|
||||
hispanic NUMERIC(4, 2) NOT NULL CHECK (hispanic >= 0),
|
||||
men NUMERIC(4, 2) NOT NULL CHECK (men >= 0),
|
||||
woman NUMERIC(4, 2) NOT NULL CHECK (woman >= 0)
|
||||
);""")
|
||||
|
||||
df = pandas.DataFrame(pandas.read_csv(filename)).dropna()
|
||||
|
||||
for row in df.itertuples():
|
||||
cur.execute("INSERT INTO unemployment VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);",
|
||||
(str(row.Year) + '-' + str(month_to_int[row.Month]) + '-1', row.Primary_School, row.High_School, row.Associates_Degree, row.Professional_Degree, row.White, row.Black, row.Asian, row.Hispanic, row.Men, row.Women))
|
||||
|
||||
connection.commit()
|
||||
cur.close()
|
||||
|
||||
def append_data(connection: psycopg2.connection, filename: str):
|
||||
# https://datahub.io/core/employment-us
|
||||
cur = connection.cursor()
|
||||
|
||||
df = pandas.DataFrame(pandas.read_csv(filename)).dropna()
|
||||
|
||||
for row in df.itertuples():
|
||||
cur.execute("INSERT INTO unemployment VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);",
|
||||
(str(row.Year) + '-' + str(month_to_int[row.Month]) + '-1', row.Primary_School, row.High_School, row.Associates_Degree, row.Professional_Degree, row.White, row.Black, row.Asian, row.Hispanic, row.Men, row.Women))
|
||||
|
||||
connection.commit()
|
||||
cur.close()
|
||||
|
||||
def graph_evolution(connection: psycopg2.connection):
|
||||
df = pandas.read_sql("""SELECT * FROM unemployment ORDER BY year_month;""", con=connection)
|
||||
fig = df.plot(x='year_month', y=['primary_school', 'high_school', 'associates_degree', 'professional_degree'])
|
||||
fig.set_xlabel('Period')
|
||||
fig.set_ylabel('Unemployement percentage')
|
||||
|
||||
fig = df.plot(x='year_month', y=['white', 'black', 'asian', 'hispanic'])
|
||||
fig.set_xlabel('Period')
|
||||
fig.set_ylabel('Unemployement percentage')
|
||||
|
||||
fig = df.plot(x='year_month', y=['men', 'woman'])
|
||||
fig.set_xlabel('Period')
|
||||
fig.set_ylabel('Unemployement percentage')
|
||||
|
||||
if __name__ == '__main__':
|
||||
db_host = input('Nom d\'hôte : ')
|
||||
if not db_host:
|
||||
db_host = 'berlin'
|
||||
db_name = input('Nom de la base de données : ')
|
||||
if not db_name:
|
||||
db_name = 'dbclfreville2'
|
||||
db_user = input('Utilisateur : ')
|
||||
if not db_user:
|
||||
db_user = 'clfreville2'
|
||||
db_password = getpass('Mot de passe : ')
|
||||
|
||||
connection = psycopg2.connect(host=db_host, port=5432, database=db_name, user=db_user, password=db_password)
|
||||
|
||||
#create_table(connection, 'unemployment_data_us.csv')
|
||||
graph_evolution(connection)
|
||||
|
||||
connection.close()
|
||||
|
||||
plt.show()
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,40 @@
|
||||
digraph mld {
|
||||
node [shape=plain]
|
||||
rankdir=LR;
|
||||
N0[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>currency</i></td></tr>
|
||||
<tr><td><u>iso</u></td></tr>
|
||||
<tr><td>full_name</td></tr>
|
||||
</table>>];
|
||||
N1[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>cuisine</i></td></tr>
|
||||
<tr><td><u>id</u></td></tr>
|
||||
<tr><td>name</td></tr>
|
||||
</table>>];
|
||||
N2[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>restaurant</i></td></tr>
|
||||
<tr><td><u>id</u></td></tr>
|
||||
<tr><td>name</td></tr>
|
||||
<tr><td>location</td></tr>
|
||||
<tr><td>min_price</td></tr>
|
||||
<tr><td>max_price</td></tr>
|
||||
<tr><td>##currency</td></tr>
|
||||
<tr><td>latitude</td></tr>
|
||||
<tr><td>longitude</td></tr>
|
||||
<tr><td>phone_number</td></tr>
|
||||
<tr><td>url</td></tr>
|
||||
<tr><td>website_url</td></tr>
|
||||
</table>>];
|
||||
N3[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>cuisine_restaurant</i></td></tr>
|
||||
<tr><td><u>##restaurant</u></td></tr>
|
||||
<tr><td><u>##cuisine</u></td></tr>
|
||||
</table>>];
|
||||
N2 -> N0[label=""];
|
||||
N3 -> N2[label=""];
|
||||
N3 -> N1[label=""];
|
||||
}
|
Binary file not shown.
@ -0,0 +1,100 @@
|
||||
%% Creator: Inkscape inkscape 0.92.4, www.inkscape.org
|
||||
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
|
||||
%% Accompanies image file 'mld.pdf' (pdf, eps, ps)
|
||||
%%
|
||||
%% To include the image in your LaTeX document, write
|
||||
%% \input{<filename>.pdf_tex}
|
||||
%% instead of
|
||||
%% \includegraphics{<filename>.pdf}
|
||||
%% To scale the image, write
|
||||
%% \def\svgwidth{<desired width>}
|
||||
%% \input{<filename>.pdf_tex}
|
||||
%% instead of
|
||||
%% \includegraphics[width=<desired width>]{<filename>.pdf}
|
||||
%%
|
||||
%% Images with a different path to the parent latex file can
|
||||
%% be accessed with the `import' package (which may need to be
|
||||
%% installed) using
|
||||
%% \usepackage{import}
|
||||
%% in the preamble, and then including the image with
|
||||
%% \import{<path to file>}{<filename>.pdf_tex}
|
||||
%% Alternatively, one can specify
|
||||
%% \graphicspath{{<path to file>/}}
|
||||
%%
|
||||
%% For more information, please see info/svg-inkscape on CTAN:
|
||||
%% http://tug.ctan.org/tex-archive/info/svg-inkscape
|
||||
%%
|
||||
\begingroup%
|
||||
\makeatletter%
|
||||
\providecommand\color[2][]{%
|
||||
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
|
||||
\renewcommand\color[2][]{}%
|
||||
}%
|
||||
\providecommand\transparent[1]{%
|
||||
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
|
||||
\renewcommand\transparent[1]{}%
|
||||
}%
|
||||
\providecommand\rotatebox[2]{#2}%
|
||||
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
|
||||
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
|
||||
\ifx\svgwidth\undefined%
|
||||
\setlength{\unitlength}{411bp}%
|
||||
\ifx\svgscale\undefined%
|
||||
\relax%
|
||||
\else%
|
||||
\setlength{\unitlength}{\unitlength * \real{\svgscale}}%
|
||||
\fi%
|
||||
\else%
|
||||
\setlength{\unitlength}{\svgwidth}%
|
||||
\fi%
|
||||
\global\let\svgwidth\undefined%
|
||||
\global\let\svgscale\undefined%
|
||||
\makeatother%
|
||||
\begin{picture}(1,0.83090024)%
|
||||
\lineheight{1}%
|
||||
\setlength\tabcolsep{0pt}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=1]{mld.pdf}}%
|
||||
\put(0.82116788,0.35961071){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{currency}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=2]{mld.pdf}}%
|
||||
\put(0.87226277,0.30851582){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}iso\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=3]{mld.pdf}}%
|
||||
\put(0.81143552,0.25498784){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}full_name\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=4]{mld.pdf}}%
|
||||
\put(0.51459854,0.78783452){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{cuisine}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=5]{mld.pdf}}%
|
||||
\put(0.55961071,0.73673963){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}id\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=6]{mld.pdf}}%
|
||||
\put(0.5243309,0.68321165){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}name\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=7]{mld.pdf}}%
|
||||
\put(0.48418491,0.59075427){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{restaurant}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=8]{mld.pdf}}%
|
||||
\put(0.56082725,0.53965937){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}id\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=9]{mld.pdf}}%
|
||||
\put(0.52554745,0.48613139){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}name\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=10]{mld.pdf}}%
|
||||
\put(0.50729927,0.4350365){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}location\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=11]{mld.pdf}}%
|
||||
\put(0.49148418,0.38394161){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}min_price\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=12]{mld.pdf}}%
|
||||
\put(0.48540146,0.33284672){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}max_price\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=13]{mld.pdf}}%
|
||||
\put(0.48540146,0.28175183){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}#currency\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=14]{mld.pdf}}%
|
||||
\put(0.50973236,0.23065694){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}latitude\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=15]{mld.pdf}}%
|
||||
\put(0.49513382,0.17956205){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}longitude\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=16]{mld.pdf}}%
|
||||
\put(0.44403893,0.12846715){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}phone_number\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=17]{mld.pdf}}%
|
||||
\put(0.55352798,0.07737226){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}url\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=18]{mld.pdf}}%
|
||||
\put(0.47688564,0.02627737){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}website_url\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=19]{mld.pdf}}%
|
||||
\put(0.01824818,0.57372264){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{cuisine_restaurant}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=20]{mld.pdf}}%
|
||||
\put(0.0729927,0.52262774){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}#restaurant\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=21]{mld.pdf}}%
|
||||
\put(0.10462287,0.47153285){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}#cuisine\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=22]{mld.pdf}}%
|
||||
\end{picture}%
|
||||
\endgroup%
|
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 38 KiB |
@ -0,0 +1,26 @@
|
||||
\relax
|
||||
\providecommand\hyper@newdestlabel[2]{}
|
||||
\catcode `:\active
|
||||
\catcode `;\active
|
||||
\catcode `!\active
|
||||
\catcode `?\active
|
||||
\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument}
|
||||
\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined
|
||||
\global\let\oldcontentsline\contentsline
|
||||
\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
|
||||
\global\let\oldnewlabel\newlabel
|
||||
\gdef\newlabel#1#2{\newlabelxx{#1}#2}
|
||||
\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
|
||||
\AtEndDocument{\ifx\hyper@anchor\@undefined
|
||||
\let\contentsline\oldcontentsline
|
||||
\let\newlabel\oldnewlabel
|
||||
\fi}
|
||||
\fi}
|
||||
\global\let\hyper@last\relax
|
||||
\gdef\HyperFirstAtBeginDocument#1{#1}
|
||||
\providecommand\HyField@AuxAddToFields[1]{}
|
||||
\providecommand\HyField@AuxAddToCoFields[2]{}
|
||||
\babel@aux{french}{}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {1}Jeu de donn\IeC {\'e}es}{1}{section.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2}Mod\IeC {\`e}le de donn\IeC {\'e}es}{1}{section.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {3}Analyse}{2}{section.3}\protected@file@percent }
|
Binary file not shown.
@ -0,0 +1,433 @@
|
||||
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=pdflatex 2021.7.23) 16 MAY 2022 17:26
|
||||
entering extended mode
|
||||
restricted \write18 enabled.
|
||||
%&-line parsing enabled.
|
||||
**rapport.tex
|
||||
(./rapport.tex
|
||||
LaTeX2e <2018-12-01>
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
|
||||
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
|
||||
File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
|
||||
)
|
||||
\c@part=\count80
|
||||
\c@section=\count81
|
||||
\c@subsection=\count82
|
||||
\c@subsubsection=\count83
|
||||
\c@paragraph=\count84
|
||||
\c@subparagraph=\count85
|
||||
\c@figure=\count86
|
||||
\c@table=\count87
|
||||
\abovecaptionskip=\skip41
|
||||
\belowcaptionskip=\skip42
|
||||
\bibindent=\dimen102
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
|
||||
Package: babel 2018/11/13 3.27 The Babel package
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def
|
||||
File: switch.def 2018/11/13 3.27 Babel switching mechanism
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/babel-french/french.ldf
|
||||
Language: french 2019/01/30 v3.5d French support from the babel system
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def
|
||||
File: babel.def 2018/11/13 3.27 Babel common definitions
|
||||
\babel@savecnt=\count88
|
||||
\U@D=\dimen103
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def)
|
||||
\bbl@dirlevel=\count89
|
||||
)
|
||||
\l@acadian = a dialect from \language\l@french
|
||||
\FB@nonchar=\count90
|
||||
Package babel Info: Making : an active character on input line 414.
|
||||
Package babel Info: Making ; an active character on input line 415.
|
||||
Package babel Info: Making ! an active character on input line 416.
|
||||
Package babel Info: Making ? an active character on input line 417.
|
||||
\FBguill@level=\count91
|
||||
\FBold@everypar=\toks14
|
||||
\FB@Mht=\dimen104
|
||||
\mc@charclass=\count92
|
||||
\mc@charfam=\count93
|
||||
\mc@charslot=\count94
|
||||
\std@mcc=\count95
|
||||
\dec@mcc=\count96
|
||||
\c@FBcaption@count=\count97
|
||||
\listindentFB=\dimen105
|
||||
\descindentFB=\dimen106
|
||||
\labelindentFB=\dimen107
|
||||
\labelwidthFB=\dimen108
|
||||
\leftmarginFB=\dimen109
|
||||
\parindentFFN=\dimen110
|
||||
\FBfnindent=\dimen111
|
||||
))
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/carlisle/scalefnt.sty)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
|
||||
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
|
||||
\KV@toks@=\toks15
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
|
||||
Package: inputenc 2018/08/11 v1.3c Input encoding file
|
||||
\inpenc@prehook=\toks16
|
||||
\inpenc@posthook=\toks17
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/tools/enumerate.sty
|
||||
Package: enumerate 2015/07/23 v3.00 enumerate extensions (DPC)
|
||||
\@enLab=\toks18
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
|
||||
Package: hyperref 2018/11/30 v6.88e Hypertext links for LaTeX
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
|
||||
Package: hobsub-hyperref 2016/05/16 v1.14 Bundle oberdiek, subset hyperref (HO)
|
||||
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty
|
||||
Package: hobsub-generic 2016/05/16 v1.14 Bundle oberdiek, subset generic (HO)
|
||||
Package: hobsub 2016/05/16 v1.14 Construct package bundles (HO)
|
||||
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
|
||||
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
|
||||
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
|
||||
Package ifluatex Info: LuaTeX not detected.
|
||||
Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
|
||||
Package ifvtex Info: VTeX not detected.
|
||||
Package: intcalc 2016/05/16 v1.2 Expandable calculations with integers (HO)
|
||||
Package: ifpdf 2018/09/07 v3.3 Provides the ifpdf switch
|
||||
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)
|
||||
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)
|
||||
Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)
|
||||
Package: pdftexcmds 2018/09/10 v0.29 Utility functions of pdfTeX for LuaTeX (HO
|
||||
)
|
||||
Package pdftexcmds Info: LuaTeX not detected.
|
||||
Package pdftexcmds Info: \pdf@primitive is available.
|
||||
Package pdftexcmds Info: \pdf@ifprimitive is available.
|
||||
Package pdftexcmds Info: \pdfdraftmode found.
|
||||
Package: pdfescape 2016/05/16 v1.14 Implements pdfTeX's escape features (HO)
|
||||
Package: bigintcalc 2016/05/16 v1.4 Expandable calculations on big integers (HO
|
||||
)
|
||||
Package: bitset 2016/05/16 v1.2 Handle bit-vector datatype (HO)
|
||||
Package: uniquecounter 2016/05/16 v1.3 Provide unlimited unique counter (HO)
|
||||
)
|
||||
Package hobsub Info: Skipping package `hobsub' (already loaded).
|
||||
Package: letltxmacro 2016/05/16 v1.5 Let assignment for LaTeX macros (HO)
|
||||
Package: hopatch 2016/05/16 v1.3 Wrapper for package hooks (HO)
|
||||
Package: xcolor-patch 2016/05/16 xcolor patch
|
||||
Package: atveryend 2016/05/16 v1.9 Hooks at the very end of document (HO)
|
||||
Package atveryend Info: \enddocument detected (standard20110627).
|
||||
Package: atbegshi 2016/06/09 v1.18 At begin shipout hook (HO)
|
||||
Package: refcount 2016/05/16 v3.5 Data extraction from label references (HO)
|
||||
Package: hycolor 2016/05/16 v1.8 Color options for hyperref/bookmark (HO)
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty
|
||||
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty
|
||||
Package: auxhook 2016/05/16 v1.4 Hooks for auxiliary files (HO)
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
|
||||
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)
|
||||
)
|
||||
\@linkdim=\dimen112
|
||||
\Hy@linkcounter=\count98
|
||||
\Hy@pagecounter=\count99
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def
|
||||
File: pd1enc.def 2018/11/30 v6.88e Hyperref: PDFDocEncoding definition (HO)
|
||||
Now handling font encoding PD1 ...
|
||||
... no UTF-8 mapping file for font encoding PD1
|
||||
)
|
||||
\Hy@SavedSpaceFactor=\count100
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg
|
||||
File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
|
||||
)
|
||||
Package hyperref Info: Hyper figures OFF on input line 4519.
|
||||
Package hyperref Info: Link nesting OFF on input line 4524.
|
||||
Package hyperref Info: Hyper index ON on input line 4527.
|
||||
Package hyperref Info: Plain pages OFF on input line 4534.
|
||||
Package hyperref Info: Backreferencing OFF on input line 4539.
|
||||
Package hyperref Info: Implicit mode ON; LaTeX internals redefined.
|
||||
Package hyperref Info: Bookmarks ON on input line 4772.
|
||||
\c@Hy@tempcnt=\count101
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty
|
||||
\Urlmuskip=\muskip10
|
||||
Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc.
|
||||
)
|
||||
LaTeX Info: Redefining \url on input line 5125.
|
||||
\XeTeXLinkMargin=\dimen113
|
||||
\Fld@menulength=\count102
|
||||
\Field@Width=\dimen114
|
||||
\Fld@charsize=\dimen115
|
||||
Package hyperref Info: Hyper figures OFF on input line 6380.
|
||||
Package hyperref Info: Link nesting OFF on input line 6385.
|
||||
Package hyperref Info: Hyper index ON on input line 6388.
|
||||
Package hyperref Info: backreferencing OFF on input line 6395.
|
||||
Package hyperref Info: Link coloring OFF on input line 6400.
|
||||
Package hyperref Info: Link coloring with OCG OFF on input line 6405.
|
||||
Package hyperref Info: PDF/A mode OFF on input line 6410.
|
||||
LaTeX Info: Redefining \ref on input line 6450.
|
||||
LaTeX Info: Redefining \pageref on input line 6454.
|
||||
\Hy@abspage=\count103
|
||||
\c@Item=\count104
|
||||
\c@Hfootnote=\count105
|
||||
)
|
||||
Package hyperref Info: Driver (autodetected): hpdftex.
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def
|
||||
File: hpdftex.def 2018/11/30 v6.88e Hyperref driver for pdfTeX
|
||||
\Fld@listcount=\count106
|
||||
\c@bookmark@seq@number=\count107
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty
|
||||
Package: rerunfilecheck 2016/05/16 v1.8 Rerun checks for auxiliary files (HO)
|
||||
Package uniquecounter Info: New unique counter `rerunfilecheck' on input line 2
|
||||
82.
|
||||
)
|
||||
\Hy@SectionHShift=\skip43
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/dirtytalk/dirtytalk.sty
|
||||
Package: dirtytalk 2010/11/21 A package making "quoting" easier
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty
|
||||
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
|
||||
)
|
||||
\c@dirtytalk@qdepth=\count108
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphviz/graphviz.sty
|
||||
Package: graphviz 2013/08/15 v0.94 .dtx graphviz file
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
|
||||
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
|
||||
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty
|
||||
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
|
||||
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
|
||||
)
|
||||
Package graphics Info: Driver file: pdftex.def on input line 99.
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def
|
||||
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
|
||||
))
|
||||
\Gin@req@height=\dimen116
|
||||
\Gin@req@width=\dimen117
|
||||
))
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
|
||||
Package: geometry 2018/04/16 v5.8 Page Geometry
|
||||
\Gm@cnth=\count109
|
||||
\Gm@cntv=\count110
|
||||
\c@Gm@tempcnt=\count111
|
||||
\Gm@bindingoffset=\dimen118
|
||||
\Gm@wd@mp=\dimen119
|
||||
\Gm@odd@mp=\dimen120
|
||||
\Gm@even@mp=\dimen121
|
||||
\Gm@layoutwidth=\dimen122
|
||||
\Gm@layoutheight=\dimen123
|
||||
\Gm@layouthoffset=\dimen124
|
||||
\Gm@layoutvoffset=\dimen125
|
||||
\Gm@dimlist=\toks19
|
||||
)
|
||||
|
||||
LaTeX Warning: Unused global option(s):
|
||||
[fontsize=12pt].
|
||||
|
||||
(./rapport.aux)
|
||||
\openout1 = `rapport.aux'.
|
||||
|
||||
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 16.
|
||||
LaTeX Font Info: ... okay on input line 16.
|
||||
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 16.
|
||||
LaTeX Font Info: ... okay on input line 16.
|
||||
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 16.
|
||||
LaTeX Font Info: ... okay on input line 16.
|
||||
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 16.
|
||||
LaTeX Font Info: ... okay on input line 16.
|
||||
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 16.
|
||||
LaTeX Font Info: ... okay on input line 16.
|
||||
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 16.
|
||||
LaTeX Font Info: ... okay on input line 16.
|
||||
LaTeX Font Info: Checking defaults for PD1/pdf/m/n on input line 16.
|
||||
LaTeX Font Info: ... okay on input line 16.
|
||||
LaTeX Info: Redefining \degres on input line 16.
|
||||
LaTeX Info: Redefining \dots on input line 16.
|
||||
Package french.ldf Info: Setting StandardEnumerateEnv=true for
|
||||
(french.ldf) compatibility with enumerate package,
|
||||
(french.ldf) reported on input line 16.
|
||||
LaTeX Info: Redefining \up on input line 16.
|
||||
|
||||
|
||||
Package french.ldf Warning: OT1 encoding should not be used for French.
|
||||
(french.ldf) Add \usepackage[T1]{fontenc} to the preamble
|
||||
(french.ldf) of your document; reported on input line 16.
|
||||
|
||||
\AtBeginShipoutBox=\box27
|
||||
Package hyperref Info: Link coloring OFF on input line 16.
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
|
||||
Package: nameref 2016/05/21 v2.44 Cross-referencing by name of section
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty
|
||||
Package: gettitlestring 2016/05/16 v1.5 Cleanup title references (HO)
|
||||
)
|
||||
\c@section@level=\count112
|
||||
)
|
||||
LaTeX Info: Redefining \ref on input line 16.
|
||||
LaTeX Info: Redefining \pageref on input line 16.
|
||||
LaTeX Info: Redefining \nameref on input line 16.
|
||||
|
||||
(./rapport.out) (./rapport.out)
|
||||
\@outlinefile=\write3
|
||||
\openout3 = `rapport.out'.
|
||||
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
|
||||
[Loading MPS to PDF converter (version 2006.09.02).]
|
||||
\scratchcounter=\count113
|
||||
\scratchdimen=\dimen126
|
||||
\scratchbox=\box28
|
||||
\nofMPsegments=\count114
|
||||
\nofMParguments=\count115
|
||||
\everyMPshowfont=\toks20
|
||||
\MPscratchCnt=\count116
|
||||
\MPscratchDim=\dimen127
|
||||
\MPnumerator=\count117
|
||||
\makeMPintoPDFobject=\count118
|
||||
\everyMPtoPDFconversion=\toks21
|
||||
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
|
||||
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
|
||||
Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)
|
||||
)
|
||||
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
|
||||
38.
|
||||
Package grfext Info: Graphics extension search list:
|
||||
(grfext) [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE
|
||||
G,.JBIG2,.JB2,.eps]
|
||||
(grfext) \AppendGraphicsExtensions on input line 456.
|
||||
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
|
||||
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
|
||||
e
|
||||
))
|
||||
*geometry* driver: auto-detecting
|
||||
*geometry* detected driver: pdftex
|
||||
*geometry* verbose mode - [ preamble ] result:
|
||||
* driver: pdftex
|
||||
* paper: a4paper
|
||||
* layout: <same size as paper>
|
||||
* layoutoffset:(h,v)=(0.0pt,0.0pt)
|
||||
* modes:
|
||||
* h-part:(L,W,R)=(81.94394pt, 433.62pt, 81.94394pt)
|
||||
* v-part:(T,H,B)=(106.75473pt, 578.15999pt, 160.13213pt)
|
||||
* \paperwidth=597.50787pt
|
||||
* \paperheight=845.04684pt
|
||||
* \textwidth=433.62pt
|
||||
* \textheight=578.15999pt
|
||||
* \oddsidemargin=9.67395pt
|
||||
* \evensidemargin=9.67395pt
|
||||
* \topmargin=-2.51526pt
|
||||
* \headheight=12.0pt
|
||||
* \headsep=25.0pt
|
||||
* \topskip=10.0pt
|
||||
* \footskip=30.0pt
|
||||
* \marginparwidth=65.0pt
|
||||
* \marginparsep=11.0pt
|
||||
* \columnsep=10.0pt
|
||||
* \skip\footins=9.0pt plus 4.0pt minus 2.0pt
|
||||
* \hoffset=0.0pt
|
||||
* \voffset=0.0pt
|
||||
* \mag=1000
|
||||
* \@twocolumnfalse
|
||||
* \@twosidefalse
|
||||
* \@mparswitchfalse
|
||||
* \@reversemarginfalse
|
||||
* (1in=72.27pt=25.4mm, 1cm=28.453pt)
|
||||
|
||||
LaTeX Font Info: External font `cmex10' loaded for size
|
||||
(Font) <12> on input line 19.
|
||||
LaTeX Font Info: External font `cmex10' loaded for size
|
||||
(Font) <8> on input line 19.
|
||||
LaTeX Font Info: External font `cmex10' loaded for size
|
||||
(Font) <6> on input line 19.
|
||||
(./rapport.toc)
|
||||
\tf@toc=\write4
|
||||
\openout4 = `rapport.toc'.
|
||||
|
||||
LaTeX Font Info: External font `cmex10' loaded for size
|
||||
(Font) <7> on input line 32.
|
||||
LaTeX Font Info: External font `cmex10' loaded for size
|
||||
(Font) <5> on input line 32.
|
||||
runsystem(dot -Tpdf -o mld.pdf mld.dot)...disabled (restricted).
|
||||
|
||||
<mld.pdf, id=20, 411.5375pt x 415.5525pt>
|
||||
File: mld.pdf Graphic file (type pdf)
|
||||
<use mld.pdf>
|
||||
Package pdftex.def Info: mld.pdf used on input line 36.
|
||||
(pdftex.def) Requested size: 411.5365pt x 415.55148pt.
|
||||
\dotfile=\write5
|
||||
\openout5 = `mld.dot'.
|
||||
|
||||
[1
|
||||
|
||||
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
|
||||
<most-common-cuisines.png, id=34, 813.0375pt x 346.896pt>
|
||||
File: most-common-cuisines.png Graphic file (type png)
|
||||
<use most-common-cuisines.png>
|
||||
Package pdftex.def Info: most-common-cuisines.png used on input line 81.
|
||||
(pdftex.def) Requested size: 433.62pt x 185.0079pt.
|
||||
|
||||
Overfull \hbox (15.0pt too wide) in paragraph at lines 81--82
|
||||
[][]
|
||||
[]
|
||||
|
||||
[2 <./mld.pdf>]
|
||||
<restaurants-currencies.png, id=54, 462.528pt x 346.896pt>
|
||||
File: restaurants-currencies.png Graphic file (type png)
|
||||
<use restaurants-currencies.png>
|
||||
Package pdftex.def Info: restaurants-currencies.png used on input line 85.
|
||||
(pdftex.def) Requested size: 433.62pt x 325.23007pt.
|
||||
|
||||
Overfull \hbox (15.0pt too wide) in paragraph at lines 85--86
|
||||
[][]
|
||||
[]
|
||||
|
||||
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 87.
|
||||
[3 <./most-common-cuisines.png> <./restaurants-currencies.png>]
|
||||
Package atveryend Info: Empty hook `AfterLastShipout' on input line 87.
|
||||
(./rapport.aux)
|
||||
Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 87.
|
||||
Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 87.
|
||||
Package rerunfilecheck Info: File `rapport.out' has not changed.
|
||||
(rerunfilecheck) Checksum: D35FA7175A597D6DA1CEF7C72F88C445;152.
|
||||
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 87.
|
||||
)
|
||||
Here is how much of TeX's memory you used:
|
||||
6853 strings out of 494532
|
||||
101410 string characters out of 6176185
|
||||
204092 words of memory out of 5000000
|
||||
10457 multiletter control sequences out of 15000+600000
|
||||
7934 words of font info for 28 fonts, out of 8000000 for 9000
|
||||
14 hyphenation exceptions out of 8191
|
||||
32i,7n,31p,537b,423s stack positions out of 5000i,500n,10000p,200000b,80000s
|
||||
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></us
|
||||
r/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/shar
|
||||
e/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texl
|
||||
ive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share/texlive/tex
|
||||
mf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share/texlive/texmf-dist
|
||||
/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/share/texlive/texmf-dist/fonts/
|
||||
type1/public/amsfonts/cm/cmti10.pfb></usr/share/texlive/texmf-dist/fonts/type1/
|
||||
urw/times/utmr8a.pfb></usr/share/texlive/texmf-dist/fonts/type1/urw/times/utmri
|
||||
8a.pfb>
|
||||
Output written on rapport.pdf (3 pages, 230862 bytes).
|
||||
PDF statistics:
|
||||
91 PDF objects out of 1000 (max. 8388607)
|
||||
69 compressed objects within 1 object stream
|
||||
8 named destinations out of 1000 (max. 500000)
|
||||
40 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,87 @@
|
||||
\documentclass[fontsize=12pt]{article}
|
||||
|
||||
\usepackage[french]{babel}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{enumerate}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{dirtytalk}
|
||||
\usepackage[pdf]{graphviz}
|
||||
|
||||
\title{SAÉ S2.04 - Exploitation de base de données}
|
||||
\author{Clément Fréville, Bastien Ollier, Nathan Dauga}
|
||||
\date{7 mai 2022}
|
||||
|
||||
\usepackage[a4paper, total={6in, 8in}]{geometry}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
\tableofcontents
|
||||
|
||||
\section{Jeu de données}
|
||||
|
||||
À partir des références présentées dans le \textit{guide Michelin 2021} et \href{https://www.kaggle.com/datasets/ngshiheng/michelin-guide-restaurants-2021}{présentées au format CSV}, nous allons étudier les tendances présentes.
|
||||
|
||||
Chaque restaurant est d'abord caractérisé par son nom, son adresse et ses informations de contact. Les restaurants proposant une cuisine de qualité sont récompensés par une, deux voire trois \say{Étoiles Michelin}. Elles définissent de très bonnes tables pour une étoile et une cuisine exceptionnelle pour trois étoiles. Le \say{Bib Gourmand} récompense quant à lui les repas soignés à prix modéré. Le critère du guide est de pouvoir commander trois plats complets pour environ 39 euros.
|
||||
|
||||
Chaque restaurant propose un ou plusieurs genres de cuisines. Une cuisine peut être \say{régionale}, \say{française} ou \say{moderne} par exemple. Le \textit{guide Michelin} fournit également un prix minimal et maximal pour une monnaie donnée.
|
||||
|
||||
\section{Modèle de données}
|
||||
|
||||
Nous avons déduit à partir de ce jeu de données une entité \textbf{restaurant} et une entité \textbf{cuisine}. À partir d'un autre jeu de données, nous avons extrait une nouvelle entité \textbf{monnaie}. Un restaurant \textit{propose} de $1$ à $n$ cuisines et \textit{utilise} $1$ monnaie.
|
||||
|
||||
Nous en déduisons le \textit{Modèle Logique de Données} suivant :
|
||||
|
||||
\digraph{mld} {
|
||||
node [shape=plain]
|
||||
rankdir=LR;
|
||||
N0[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>currency</i></td></tr>
|
||||
<tr><td><u>iso</u></td></tr>
|
||||
<tr><td>full_name</td></tr>
|
||||
</table>>];
|
||||
N1[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>cuisine</i></td></tr>
|
||||
<tr><td><u>id</u></td></tr>
|
||||
<tr><td>name</td></tr>
|
||||
</table>>];
|
||||
N2[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>restaurant</i></td></tr>
|
||||
<tr><td><u>id</u></td></tr>
|
||||
<tr><td>name</td></tr>
|
||||
<tr><td>location</td></tr>
|
||||
<tr><td>min_price</td></tr>
|
||||
<tr><td>max_price</td></tr>
|
||||
<tr><td>#currency</td></tr>
|
||||
<tr><td>latitude</td></tr>
|
||||
<tr><td>longitude</td></tr>
|
||||
<tr><td>phone_number</td></tr>
|
||||
<tr><td>url</td></tr>
|
||||
<tr><td>website_url</td></tr>
|
||||
</table>>];
|
||||
N3[label=<
|
||||
<table border="0" cellborder="1" cellspacing="0">
|
||||
<tr><td><i>cuisine_restaurant</i></td></tr>
|
||||
<tr><td><u>#restaurant</u></td></tr>
|
||||
<tr><td><u>#cuisine</u></td></tr>
|
||||
</table>>];
|
||||
N2 -> N0[label=""];
|
||||
N3 -> N2[label=""];
|
||||
N3 -> N1[label=""];
|
||||
}
|
||||
|
||||
\section{Analyse}
|
||||
|
||||
Le \textit{guide Michelin} référence de nombreux genres de cuisines. Quelles sont les genres les plus présents ?
|
||||
|
||||
\includegraphics[width=\textwidth]{most-common-cuisines.png}
|
||||
|
||||
Si le \textit{guide Michelin} est essentiellement européen, quelles autres monnaies sont utilisées ?
|
||||
|
||||
\includegraphics[width=\textwidth]{restaurants-currencies.png}
|
||||
|
||||
\end{document}
|
@ -0,0 +1,4 @@
|
||||
\babel@toc {french}{}
|
||||
\contentsline {section}{\numberline {1}Jeu de donn\IeC {\'e}es}{1}{section.1}%
|
||||
\contentsline {section}{\numberline {2}Mod\IeC {\`e}le de donn\IeC {\'e}es}{1}{section.2}%
|
||||
\contentsline {section}{\numberline {3}Analyse}{2}{section.3}%
|
@ -0,0 +1,43 @@
|
||||
SELECT c.iso, c.full_name, COUNT(*) restaurants
|
||||
FROM restaurant r
|
||||
INNER JOIN currency c ON c.iso = r.currency
|
||||
GROUP BY c.iso
|
||||
ORDER BY 3 DESC
|
||||
LIMIT 10;
|
||||
|
||||
SELECT min_price
|
||||
FROM restaurant
|
||||
WHERE currency = 'EUR'
|
||||
ORDER BY min_price
|
||||
GROUP BY '[3,7)'::int4range;
|
||||
|
||||
/*WITH series AS (
|
||||
SELECT generate_series(
|
||||
(SELECT MIN(min_price) FROM restaurant),
|
||||
(SELECT MAX(min_price) FROM restaurant WHERE min_price != 'NaN'::NUMERIC),
|
||||
10
|
||||
) low_bound_price
|
||||
)
|
||||
SELECT '[' || s.low_bound_price || ',' || (s.low_bound_price+10) || '[', COUNT(*) restaurants
|
||||
FROM series s
|
||||
LEFT JOIN restaurant r
|
||||
ON r.min_price >= s.low_bound_price
|
||||
AND r.min_price < (s.low_bound_price + 10)
|
||||
GROUP BY low_bound_price;*/
|
||||
|
||||
-- COUNT(*) FILTER ?
|
||||
SELECT CASE WHEN min_price < 5 THEN '< 5'
|
||||
WHEN min_price >= 5 AND min_price < 10 THEN '[5;10['
|
||||
WHEN min_price >= 10 AND min_price < 15 THEN '[10;15['
|
||||
WHEN min_price >= 15 AND min_price < 20 THEN '[15;20['
|
||||
WHEN min_price >= 20 AND min_price < 30 THEN '[20;30['
|
||||
WHEN min_price >= 30 AND min_price < 50 THEN '[30;50['
|
||||
WHEN min_price >= 50 AND min_price < 100 THEN '[50;100['
|
||||
WHEN min_price >= 100 AND min_price < 200 THEN '[100;200['
|
||||
WHEN min_price >= 200 AND min_price < 500 THEN '[200;500['
|
||||
WHEN min_price >= 500 AND min_price < 1000 THEN '[500;1000['
|
||||
WHEN min_price >= 1000 THEN '>= 1000'
|
||||
END min_price_range,
|
||||
COUNT(*) nb
|
||||
FROM restaurant
|
||||
GROUP BY min_price_range;
|
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
@ -0,0 +1,100 @@
|
||||
%% Creator: Inkscape inkscape 0.92.4, www.inkscape.org
|
||||
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
|
||||
%% Accompanies image file 'mld_svg-tex.pdf' (pdf, eps, ps)
|
||||
%%
|
||||
%% To include the image in your LaTeX document, write
|
||||
%% \input{<filename>.pdf_tex}
|
||||
%% instead of
|
||||
%% \includegraphics{<filename>.pdf}
|
||||
%% To scale the image, write
|
||||
%% \def\svgwidth{<desired width>}
|
||||
%% \input{<filename>.pdf_tex}
|
||||
%% instead of
|
||||
%% \includegraphics[width=<desired width>]{<filename>.pdf}
|
||||
%%
|
||||
%% Images with a different path to the parent latex file can
|
||||
%% be accessed with the `import' package (which may need to be
|
||||
%% installed) using
|
||||
%% \usepackage{import}
|
||||
%% in the preamble, and then including the image with
|
||||
%% \import{<path to file>}{<filename>.pdf_tex}
|
||||
%% Alternatively, one can specify
|
||||
%% \graphicspath{{<path to file>/}}
|
||||
%%
|
||||
%% For more information, please see info/svg-inkscape on CTAN:
|
||||
%% http://tug.ctan.org/tex-archive/info/svg-inkscape
|
||||
%%
|
||||
\begingroup%
|
||||
\makeatletter%
|
||||
\providecommand\color[2][]{%
|
||||
\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
|
||||
\renewcommand\color[2][]{}%
|
||||
}%
|
||||
\providecommand\transparent[1]{%
|
||||
\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
|
||||
\renewcommand\transparent[1]{}%
|
||||
}%
|
||||
\providecommand\rotatebox[2]{#2}%
|
||||
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
|
||||
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
|
||||
\ifx\svgwidth\undefined%
|
||||
\setlength{\unitlength}{411bp}%
|
||||
\ifx\svgscale\undefined%
|
||||
\relax%
|
||||
\else%
|
||||
\setlength{\unitlength}{\unitlength * \real{\svgscale}}%
|
||||
\fi%
|
||||
\else%
|
||||
\setlength{\unitlength}{\svgwidth}%
|
||||
\fi%
|
||||
\global\let\svgwidth\undefined%
|
||||
\global\let\svgscale\undefined%
|
||||
\makeatother%
|
||||
\begin{picture}(1,0.83090024)%
|
||||
\lineheight{1}%
|
||||
\setlength\tabcolsep{0pt}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=1]{mld_svg-tex.pdf}}%
|
||||
\put(0.82116788,0.35961071){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{currency}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=2]{mld_svg-tex.pdf}}%
|
||||
\put(0.87226277,0.30851582){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}iso\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=3]{mld_svg-tex.pdf}}%
|
||||
\put(0.81143552,0.25498784){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}full_name\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=4]{mld_svg-tex.pdf}}%
|
||||
\put(0.51459854,0.78783452){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{cuisine}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=5]{mld_svg-tex.pdf}}%
|
||||
\put(0.55961071,0.73673963){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}id\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=6]{mld_svg-tex.pdf}}%
|
||||
\put(0.5243309,0.68321165){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}name\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=7]{mld_svg-tex.pdf}}%
|
||||
\put(0.48418491,0.59075427){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{restaurant}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=8]{mld_svg-tex.pdf}}%
|
||||
\put(0.56082725,0.53965937){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}id\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=9]{mld_svg-tex.pdf}}%
|
||||
\put(0.52554745,0.48613139){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}name\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=10]{mld_svg-tex.pdf}}%
|
||||
\put(0.50729927,0.4350365){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}location\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=11]{mld_svg-tex.pdf}}%
|
||||
\put(0.49148418,0.38394161){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}min_price\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=12]{mld_svg-tex.pdf}}%
|
||||
\put(0.48540146,0.33284672){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}max_price\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=13]{mld_svg-tex.pdf}}%
|
||||
\put(0.48540146,0.28175183){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}#currency\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=14]{mld_svg-tex.pdf}}%
|
||||
\put(0.50973236,0.23065694){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}latitude\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=15]{mld_svg-tex.pdf}}%
|
||||
\put(0.49513382,0.17956205){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}longitude\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=16]{mld_svg-tex.pdf}}%
|
||||
\put(0.44403893,0.12846715){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}phone_number\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=17]{mld_svg-tex.pdf}}%
|
||||
\put(0.55352798,0.07737226){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}url\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=18]{mld_svg-tex.pdf}}%
|
||||
\put(0.47688564,0.02627737){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}website_url\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=19]{mld_svg-tex.pdf}}%
|
||||
\put(0.01824818,0.57372264){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}\textit{cuisine_restaurant}\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=20]{mld_svg-tex.pdf}}%
|
||||
\put(0.0729927,0.52262774){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}#restaurant\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=21]{mld_svg-tex.pdf}}%
|
||||
\put(0.10462287,0.47153285){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}#cuisine\end{tabular}}}}%
|
||||
\put(0,0){\includegraphics[width=\unitlength,page=22]{mld_svg-tex.pdf}}%
|
||||
\end{picture}%
|
||||
\endgroup%
|
@ -0,0 +1,30 @@
|
||||
CREATE TABLE currency (
|
||||
iso CHAR(3) PRIMARY KEY,
|
||||
full_name VARCHAR(40) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE cuisine (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(30)
|
||||
);
|
||||
|
||||
CREATE TABLE restaurant (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
location VARCHAR(150) NOT NULL,
|
||||
min_price NUMERIC(9, 2) NOT NULL,
|
||||
max_price NUMERIC(9, 2) NOT NULL,
|
||||
currency CHAR(3) REFERENCES currency(iso),
|
||||
latitude FLOAT,
|
||||
longitude FLOAT,
|
||||
phone_number VARCHAR(16),
|
||||
url VARCHAR(255) NOT NULL,
|
||||
website_url VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE cuisine_restaurant (
|
||||
restaurant INT REFERENCES restaurant(id),
|
||||
cuisine INT REFERENCES cuisine(id),
|
||||
PRIMARY KEY(restaurant, cuisine)
|
||||
);
|
||||
-- TODO : pourquoi sqlship ne gère pas les if not exists ???????
|
@ -0,0 +1,40 @@
|
||||
-- https://www.kaggle.com/datasets/ngshiheng/michelin-guide-restaurants-2021
|
||||
-- https://docs.openexchangerates.org/docs/currencies-json
|
||||
|
||||
DROP TABLE IF EXISTS cuisine_restaurant;
|
||||
DROP TABLE IF EXISTS restaurant;
|
||||
DROP TABLE IF EXISTS currency;
|
||||
DROP TABLE IF EXISTS cuisine;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS currency (
|
||||
iso CHAR(3) PRIMARY KEY, -- ISO 4217
|
||||
full_name VARCHAR(40) NOT NULL,
|
||||
UNIQUE(full_name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cuisine (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(30),
|
||||
UNIQUE (name)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS restaurant (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
location VARCHAR(150) NOT NULL,
|
||||
min_price NUMERIC(9, 2) NOT NULL,
|
||||
max_price NUMERIC(9, 2) NOT NULL,
|
||||
currency CHAR(3) REFERENCES currency(iso),
|
||||
latitude FLOAT,
|
||||
longitude FLOAT,
|
||||
phone_number VARCHAR(16),
|
||||
url VARCHAR(255) NOT NULL,
|
||||
website_url VARCHAR(255) NOT NULL,
|
||||
stars INT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cuisine_restaurant (
|
||||
restaurant INT REFERENCES restaurant(id),
|
||||
cuisine INT REFERENCES cuisine(id),
|
||||
PRIMARY KEY(restaurant, cuisine)
|
||||
);
|
|
@ -0,0 +1,53 @@
|
||||
DROP TABLE IF EXISTS suivre;
|
||||
DROP TABLE IF EXISTS louer;
|
||||
DROP TABLE IF EXISTS instrument;
|
||||
DROP TABLE IF EXISTS eleve;
|
||||
DROP TABLE IF EXISTS professeur;
|
||||
DROP TABLE IF EXISTS niveau;
|
||||
|
||||
CREATE TABLE niveau
|
||||
(
|
||||
niveau SERIAL PRIMARY KEY,
|
||||
tarifHoraire INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE professeur
|
||||
(
|
||||
num SERIAL PRIMARY KEY,
|
||||
nom VARCHAR(255) NOT NULL,
|
||||
prenom VARCHAR(255) NOT NULL,
|
||||
noTel CHAR(10) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE eleve
|
||||
(
|
||||
num SERIAL PRIMARY KEY,
|
||||
nom VARCHAR(255) NOT NULL,
|
||||
prenom VARCHAR(255) NOT NULL,
|
||||
age INT NOT NULL,
|
||||
rue VARCHAR(255) NOT NULL,
|
||||
codePostal VARCHAR(255) NOT NULL,
|
||||
ville VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE instrument
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
designation VARCHAR(255),
|
||||
tarifLocation INT NOT NULL,
|
||||
prof INT NOT NULL REFERENCES professeur (num)
|
||||
);
|
||||
|
||||
CREATE TABLE suivre
|
||||
(
|
||||
eleve INT NOT NULL REFERENCES eleve (num),
|
||||
instrument INT NOT NULL REFERENCES instrument (id),
|
||||
niveau INT NOT NULL REFERENCES niveau (niveau)
|
||||
);
|
||||
|
||||
CREATE TABLE louer
|
||||
(
|
||||
eleve INT NOT NULL REFERENCES eleve (num),
|
||||
instrument INT NOT NULL REFERENCES instrument (id)
|
||||
);
|
||||
|
@ -0,0 +1,237 @@
|
||||
import pandas
|
||||
import psycopg2 # pip3 install types-psycopg2
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from getpass import getpass
|
||||
|
||||
##########
|
||||
# Partie 1
|
||||
##########
|
||||
|
||||
def part1_create_table(connection: psycopg2.connection, filename: str) -> pandas.DataFrame:
|
||||
cur = connection.cursor()
|
||||
|
||||
# 2. Création et population de la table
|
||||
cur.execute("""CREATE TABLE IF NOT EXISTS plain_jeu (
|
||||
nom VARCHAR(150) NOT NULL,
|
||||
plateforme VARCHAR(10) NOT NULL,
|
||||
annee_sortie INTEGER,
|
||||
genre VARCHAR(20) NOT NULL,
|
||||
editeur VARCHAR(40) NOT NULL,
|
||||
ventes_na NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_ue NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_jp NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_autre NUMERIC(6, 2) NOT NULL DEFAULT 0,
|
||||
ventes_total NUMERIC(6, 2) NOT NULL DEFAULT 0, -- Redondant vu que devrait être le total des autres colonnes des ventes
|
||||
PRIMARY KEY(nom, plateforme)
|
||||
)""")
|
||||
|
||||
ventes = pandas.read_csv(filename)
|
||||
|
||||
# 3. Élimination des doublons
|
||||
df = pandas.DataFrame(ventes).drop_duplicates(subset=['Name', 'Platform'])
|
||||
|
||||
# 2. Insertions
|
||||
for row in df.itertuples():
|
||||
cur.execute("INSERT INTO plain_jeu VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);",
|
||||
(row.Name, row.Platform, int(row.Year) if not pandas.isnull(row.Year) else None, row.Genre,
|
||||
row.Publisher, row.NA_Sales, row.EU_Sales,
|
||||
row.JP_Sales, row.Other_Sales, row.Global_Sales))
|
||||
|
||||
# 5. Recherche des lignes incohérentes (par delta vu qu'il s'agit de nombre flottants)
|
||||
cur.execute("""SELECT nom, plateforme, ROUND((ventes_na + ventes_ue + ventes_jp + ventes_autre)::numeric, 2), ventes_total
|
||||
FROM plain_jeu
|
||||
WHERE ABS(ventes_na + ventes_ue + ventes_jp + ventes_autre - ventes_total) > 0.1""")
|
||||
for row in cur.fetchall():
|
||||
print(row)
|
||||
|
||||
# 6. Recalcul des ventes pour les lignes incohérentes
|
||||
cur.execute("""UPDATE plain_jeu
|
||||
SET ventes_total = ROUND((ventes_na + ventes_ue + ventes_jp + ventes_autre)::numeric, 2)
|
||||
WHERE ABS(ventes_na + ventes_ue + ventes_jp + ventes_autre - ventes_total) > 0.1;""")
|
||||
|
||||
connection.commit()
|
||||
cur.close()
|
||||
|
||||
# 7. Création du DataFrame propre
|
||||
return pandas.read_sql("SELECT * FROM plain_jeu;", con=connection)
|
||||
|
||||
|
||||
##########
|
||||
# Partie 2
|
||||
##########
|
||||
|
||||
def part2_graphs(connection: psycopg2.connection):
|
||||
# 1. Calcul des ventes moyennes par année de sortie et pour le genre aventure
|
||||
df = pandas.read_sql("""SELECT annee_sortie, AVG(ventes_total) ventes_moyennes, SUM(ventes_total) ventes_totales FROM plain_jeu
|
||||
WHERE genre = 'Adventure' AND annee_sortie IS NOT NULL
|
||||
GROUP BY annee_sortie
|
||||
ORDER BY annee_sortie;""", con=connection)
|
||||
|
||||
# 2/3. Affichage sous forme de courbe
|
||||
fig = df.plot(x='annee_sortie', y=['ventes_moyennes', 'ventes_totales'])
|
||||
fig.legend(['Ventes moyennes', 'Ventes totales'])
|
||||
fig.set_xlabel('Année de sortie')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
# 4. Ventes totales pour l'ensemble des jeux
|
||||
df = pandas.read_sql("""SELECT annee_sortie, genre, SUM(ventes_total) ventes_totales FROM plain_jeu
|
||||
WHERE annee_sortie IS NOT NULL
|
||||
GROUP BY annee_sortie, genre
|
||||
ORDER BY annee_sortie;""", con=connection)
|
||||
fig, ax = plt.subplots()
|
||||
for i, (label, group) in enumerate(df.groupby(['genre'])):
|
||||
ax = group.plot(ax=ax, kind='line', x='annee_sortie',
|
||||
y='ventes_totales', label=label, color=plt.cm.tab20.colors[i])
|
||||
ax.set_xlabel('Année de sortie')
|
||||
ax.set_ylabel('Ventes (en millions)')
|
||||
|
||||
|
||||
##########
|
||||
# Partie 3
|
||||
##########
|
||||
|
||||
def part3_graphs(connection: psycopg2.connection):
|
||||
# 1. Calcul du total des ventes en Europe par plateforme
|
||||
df = pandas.read_sql("""SELECT plateforme, SUM(ventes_ue) ventes_ue FROM plain_jeu
|
||||
GROUP BY plateforme
|
||||
ORDER BY ventes_ue;""", con=connection)
|
||||
|
||||
def plot_ventes_ue(df: pandas.DataFrame, plot_kind: str = 'line'):
|
||||
fig = df.plot(x='plateforme', y='ventes_ue', legend=False, kind=plot_kind)
|
||||
fig.set_xlabel('Plateforme')
|
||||
fig.set_ylabel('Ventes en Europe (en millions)')
|
||||
fig.set_xticks(np.arange(len(df))) # Force l'affichage de tous les labels en abscisse
|
||||
fig.set_xticklabels(df['plateforme'])
|
||||
fig.set_title('Ventes de jeux vidéos en Europe par plateforme')
|
||||
|
||||
# 2. Affichage sous forme de courbe
|
||||
plot_ventes_ue(df)
|
||||
|
||||
# 3. Affichage sous forme d'histogramme
|
||||
# plot_ventes_ue(df, 'hist')
|
||||
plot_ventes_ue(df, 'bar')
|
||||
|
||||
# 4. Calcul du total des ventes par plateforme et par zone géographique
|
||||
df = pandas.read_sql("""SELECT plateforme, SUM(ventes_na) ventes_na, SUM(ventes_ue) ventes_ue, SUM(ventes_jp) ventes_jp, SUM(ventes_autre) ventes_autre FROM plain_jeu
|
||||
GROUP BY plateforme
|
||||
ORDER BY SUM(ventes_total);""", con=connection)
|
||||
|
||||
# 5/6. Affichage sous forme de courbes
|
||||
fig = df.plot(x='plateforme', style=[
|
||||
'r*-', 'bo--', 'y^:', 'gs-.'])
|
||||
fig.set_xticks(np.arange(len(df['plateforme'])))
|
||||
fig.set_xticklabels(df['plateforme'])
|
||||
fig.set_xlabel('Plateforme')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
fig = df.plot.bar(x='plateforme', y=[
|
||||
'ventes_na', 'ventes_ue', 'ventes_jp', 'ventes_autre'])
|
||||
fig.set_xlabel('Plateforme')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
|
||||
##########
|
||||
# Partie 4
|
||||
##########
|
||||
|
||||
def plot_ventes_jeu(cur: psycopg2.cursor, nom: str, pourcentages: bool = True):
|
||||
# 1. Récupération des ventes, réorganisées en plusieurs lignes dans le dataframe
|
||||
cur.execute("""SELECT ventes_na, ventes_ue, ventes_jp, ventes_autre FROM plain_jeu
|
||||
WHERE nom = '%s';""" % nom)
|
||||
data = cur.fetchone()
|
||||
zones = [desc[0].split('_')[1] for desc in cur.description]
|
||||
df = pandas.DataFrame([[zones[i], float(data[i])] for i in range(len(data))], columns=['zone', 'ventes'],
|
||||
index=zones)
|
||||
|
||||
title = 'Ventes du jeu ' + nom + ' par zone géographique'
|
||||
|
||||
# 2. Diagramme en bâtons
|
||||
fig = df.plot.bar(x='zone', y='ventes', legend=False, rot=0)
|
||||
fig.set_title(title)
|
||||
|
||||
if pourcentages:
|
||||
# 4. Diagramme camembert avec pourcentages
|
||||
fig = df.plot.pie(y='ventes', labels=None, autopct='%1.1f%%')
|
||||
else:
|
||||
# 3. Diagramme camembert
|
||||
fig = df.plot.pie(y='ventes', legend=False)
|
||||
fig.set_title(title)
|
||||
fig.set_xlabel('Zone géographique')
|
||||
fig.set_ylabel('Ventes (en millions)')
|
||||
|
||||
|
||||
def part4_graphs(connection: psycopg2.connection):
|
||||
with connection.cursor() as cur:
|
||||
plot_ventes_jeu(cur, 'Mario Kart 64')
|
||||
# 5. Résultats de Mario Kart Wii
|
||||
plot_ventes_jeu(cur, 'Mario Kart Wii')
|
||||
|
||||
|
||||
##########
|
||||
# Partie 5
|
||||
##########
|
||||
|
||||
def part5_graphs(connection: psycopg2.connection):
|
||||
# 1/2. Pourcentage du total des ventes par genre
|
||||
df = pandas.read_sql("""SELECT genre, SUM(ventes_total) total_ventes FROM plain_jeu
|
||||
GROUP BY genre;""", con=connection)
|
||||
df.set_index('genre', inplace=True)
|
||||
|
||||
# 3. Diagramme camembert
|
||||
fig = df.plot.pie(y='total_ventes', legend=False, autopct='%1.1f%%', colors=plt.cm.tab20.colors)
|
||||
fig.set_title('Ventes mondiales de jeux vidéos par genre')
|
||||
fig.set_ylabel('')
|
||||
|
||||
# 4. 4 camemberts du total des ventes par genre et par
|
||||
df = pandas.read_sql("""
|
||||
SELECT CASE WHEN annee_sortie < 1990 THEN '< 1990'
|
||||
WHEN annee_sortie BETWEEN 1990 AND 1999 THEN '<=> 1990-1999'
|
||||
WHEN annee_sortie BETWEEN 2000 AND 2009 THEN '<=> 2000-2009'
|
||||
WHEN annee_sortie >= 2010 THEN '>= 2010'
|
||||
END annee,
|
||||
genre,
|
||||
SUM(ventes_total) ventes_totales
|
||||
FROM plain_jeu
|
||||
WHERE annee_sortie IS NOT NULL
|
||||
GROUP BY annee, genre
|
||||
ORDER BY annee, genre;""", con=connection)
|
||||
grouped = df.groupby('annee')
|
||||
rowlength = grouped.ngroups // 2
|
||||
fig, axs = plt.subplots(figsize=(9, 4), nrows=2, ncols=rowlength)
|
||||
targets = zip(grouped.groups.keys(), axs.flatten())
|
||||
legend = []
|
||||
|
||||
for (key, ax) in targets:
|
||||
group = grouped.get_group(key)
|
||||
legend = group['genre']
|
||||
ax = group.plot.pie(ax=ax, y='ventes_totales', labels=None,
|
||||
legend=False, colors=plt.cm.tab20.colors)
|
||||
ax.set_ylabel('')
|
||||
ax.set_title(key)
|
||||
fig.legend(legend)
|
||||
fig.suptitle('Ventes de jeux vidéos par genre et par période')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
db_host = input('Nom d\'hôte : ')
|
||||
if not db_host:
|
||||
db_host = 'berlin'
|
||||
db_name = input('Nom de la base de données : ')
|
||||
if not db_name:
|
||||
db_name = 'dbclfreville2'
|
||||
db_user = input('Utilisateur : ')
|
||||
if not db_user:
|
||||
db_user = 'clfreville2'
|
||||
db_password = getpass('Mot de passe : ')
|
||||
|
||||
connection = psycopg2.connect(host=db_host, port=5432, database=db_name, user=db_user, password=db_password)
|
||||
|
||||
#part1_create_table(connection, 'vgsales.csv')
|
||||
part2_graphs(connection)
|
||||
part3_graphs(connection)
|
||||
part4_graphs(connection)
|
||||
part5_graphs(connection)
|
||||
|
||||
connection.close()
|
||||
plt.show()
|
@ -0,0 +1,44 @@
|
||||
-- 1
|
||||
SELECT rolname FROM pg_roles;
|
||||
|
||||
-- 2
|
||||
CREATE TABLE test_clfreville2
|
||||
(
|
||||
id CHAR(4) PRIMARY KEY,
|
||||
msg VARCHAR(60)
|
||||
);
|
||||
|
||||
INSERT INTO test_clfreville2 VALUES
|
||||
('AAAA', 'Félicitations vous avez découvert le premier message'),
|
||||
('BBBB', 'Saviez-vous que l''ornithorynque est un mammifère?'),
|
||||
('CCCC', 'Un tiens vaut mieux que deux tu l''auras'),
|
||||
('DDDD', 'Le boutisme (endianness) c''est le genre des entiers');
|
||||
|
||||
-- 3
|
||||
--CREATE ROLE test_clfreville2_lodufour1 LOGIN
|
||||
--VALID UNTIL '2022-05-09';
|
||||
--ALTER TABLE test_clfreville2 OWNER TO test_clfreville2_lodufour1;
|
||||
|
||||
-- 4
|
||||
ALTER TABLE test_clfreville2
|
||||
ADD nb NUMERIC;
|
||||
|
||||
-- 5
|
||||
ALTER TABLE test_lodufour1 OWNER TO lodufour1;
|
||||
|
||||
-- 6
|
||||
GRANT SELECT ON test_clfreville2 TO public;
|
||||
|
||||
--SELECT * FROM dblink('dbname=dblodufour1', 'SELECT * FROM test_lodufour1');
|
||||
|
||||
-- 7
|
||||
INSERT INTO test_lodufour1 VALUES ('DMRT', 'Jeu de l''oie');
|
||||
|
||||
-- 8
|
||||
REVOKE SELECT ON test_clfreville2 FROM public;
|
||||
|
||||
-- Connexion à une autre db depuis une connexion courante :
|
||||
GRANT CONNECT ON DATABASE dbclfreville2 TO lodufour1; -- Autorise la connexion
|
||||
GRANT INSERT ON test_clfreville2 TO lodufour1; -- Autorise l'insertion à un utilisateur
|
||||
\connect dblodufour1
|
||||
SELECT * FROM test_lodufour1;
|
@ -0,0 +1,33 @@
|
||||
-- Recalcule les lignes avec des ventes totales incohérentes
|
||||
UPDATE plain_jeu
|
||||
SET ventes_total = ROUND((ventes_na + ventes_ue + ventes_jp + ventes_autre)::numeric, 2)
|
||||
WHERE ABS(ventes_na + ventes_ue + ventes_jp + ventes_autre - ventes_total) > 0.1
|
||||
|
||||
SELECT annee_sortie, AVG(ventes_total) ventes_moyennes, SUM(ventes_total) ventes_totales FROM plain_jeu
|
||||
WHERE genre = 'Adventure' AND annee_sortie IS NOT NULL
|
||||
GROUP BY annee_sortie;
|
||||
|
||||
SELECT SUM(ventes_ue) FROM ventes
|
||||
GROUP BY plateforme;
|
||||
|
||||
SELECT * FROM plain_jeu
|
||||
WHERE nom = 'Mario Kart 64';
|
||||
|
||||
SELECT genre, SUM(ventes_total) total_ventes FROM plain_jeu
|
||||
GROUP BY genre;
|
||||
|
||||
SELECT genre, ROUND((SUM(ventes_total) / (SELECT SUM(ventes_total) FROM plain_jeu)) * 100, 2) pourcentage_ventes FROM plain_jeu
|
||||
GROUP BY genre;
|
||||
|
||||
SELECT CASE WHEN annee_sortie < 1990 THEN '< 1990'
|
||||
WHEN annee_sortie BETWEEN 1990 AND 1999 THEN '1990-1999'
|
||||
WHEN annee_sortie BETWEEN 2000 AND 2009 THEN '2000-2009'
|
||||
WHEN annee_sortie >= 2010 THEN '>= 2010'
|
||||
END annee,
|
||||
genre,
|
||||
SUM(ventes_total) ventes_totales
|
||||
FROM plain_jeu
|
||||
WHERE annee_sortie IS NOT NULL
|
||||
GROUP BY genre, annee
|
||||
ORDER BY annee;
|
||||
|
@ -0,0 +1,113 @@
|
||||
-- 1
|
||||
SELECT * FROM aeroport WHERE pays = 'France' ORDER BY ville;
|
||||
|
||||
-- 2
|
||||
SELECT v.* FROM vol v
|
||||
INNER JOIN avion a ON a.immat = v.avion
|
||||
WHERE v.compagnie != a.compagnie;
|
||||
|
||||
-- 3
|
||||
SELECT DISTINCT a.nom, a.ville, a.pays
|
||||
FROM vol v
|
||||
INNER JOIN aeroport a ON v.aeroportArr = a.code
|
||||
WHERE v.aeroportDep = (
|
||||
SELECT code FROM aeroport WHERE ville = 'Clermont-Ferrand'
|
||||
);
|
||||
|
||||
-- 4
|
||||
SELECT MAX(m.nbPassagers) FROM avion a
|
||||
INNER JOIN modele m ON m.code = a.modele
|
||||
WHERE a.compagnie = (
|
||||
SELECT numero FROM compagnie WHERE nom = 'Air France'
|
||||
);
|
||||
|
||||
-- 5
|
||||
SELECT m.nom, m.marque, a.matricule, MAX(a.dateMiseService)
|
||||
FROM avion a
|
||||
INNER JOIN modele m ON m.code = a.modele
|
||||
GROUP BY a.modele;
|
||||
|
||||
-- 6
|
||||
SELECT a.* FROM vol v
|
||||
INNER JOIN avion a ON a.immat = v.avion
|
||||
WHERE v.aeroportDep = 'CDG'
|
||||
AND v.aeroportDep = 'JFK'
|
||||
ORDER BY a.dateMiseService
|
||||
LIMIT 1;
|
||||
|
||||
-- 7 (ou jointure)
|
||||
SELECT a.*, (
|
||||
SELECT COUNT(*) FROM vol WHERE aeroportDep = a.code OR aeroportArr = a.code
|
||||
) nbVols
|
||||
FROM aeroport a
|
||||
ORDER BY a.nbVols DESC;
|
||||
|
||||
-- 8
|
||||
SELECT a.*, COUNT(*)
|
||||
FROM vol v
|
||||
INNER JOIN avion a ON a.immat = v.numero
|
||||
GROUP BY a.immat
|
||||
HAVING COUNT(*) >= 20;
|
||||
|
||||
-- 9
|
||||
SELECT a.compagnie
|
||||
FROM avion a
|
||||
INNER JOIN modele m ON m.code = a.modele
|
||||
GROUP BY a.compagnie
|
||||
HAVING COUNT(DISTINCT m.marque) = (
|
||||
SELECT COUNT(DISTINCT m.marque) FROM modele
|
||||
);
|
||||
|
||||
-- 10
|
||||
SELECT compagnie
|
||||
FROM avion
|
||||
GROUP BY compagnie
|
||||
HAVING COUNT(*) >= ALL (
|
||||
SELECT COUNT(*) c
|
||||
FROM avion
|
||||
ORDER BY c DESC
|
||||
);
|
||||
|
||||
-- 11
|
||||
SELECT a.nom
|
||||
FROM vol v
|
||||
INNER JOIN aeroport a ON a.code = v.aeroportDep
|
||||
WHERE a.pays = 'France'
|
||||
GROUP BY a.code
|
||||
HAVING COUNT(*) FILTER (WHERE v.compagnie = (
|
||||
SELECT numero FROM compagnie WHERE nom = 'Air France'
|
||||
)) >= (COUNT(*) * 3) / 4
|
||||
);
|
||||
|
||||
-- 12
|
||||
SELECT m.nom, ROUND((COUNT(*) * 100) / (
|
||||
SELECT COUNT(*) FROM avion
|
||||
WHERE compagnie = (SELECT numero FROM compagnie = 'Air France')
|
||||
), 2) pourcentage
|
||||
FROM avion a
|
||||
INNER JOIN modele m ON m.code = a.modele
|
||||
GROUP BY a.modele;
|
||||
|
||||
-- 13
|
||||
DELETE vol v
|
||||
USING avion a
|
||||
WHERE v.avion = a.immat AND v.aeroportDep > (a.dateMiseService + 10000);
|
||||
|
||||
SELECT *
|
||||
FROM vol v
|
||||
INNER JOIN aeroport depart ON depart.code = v.aeroportDep
|
||||
INNER JOIN aeroport arrive ON arrive.code = v.aeroportArr
|
||||
INNER JOIN avion a ON a.immat = v.avion
|
||||
INNER JOIN modele m ON m.code = a.modele
|
||||
WHERE depart.pays IN ('France', 'USA') AND arrive.pays IN ('France', 'USA')
|
||||
AND ((depart.pays = 'France' AND depart.ville LIKE 'C%')
|
||||
OR (depart.pays = 'USA' AND arrive.ville LIKE 'L%'))
|
||||
AND ((arrive.pays = 'France' AND arrive.ville LIKE 'C%')
|
||||
OR (arrive.pays = 'USA' AND arrive.ville LIKE 'L%'))
|
||||
AND m.nbPassagers % 3 = 0
|
||||
AND a.compagnie != v.compagnie
|
||||
AND (
|
||||
SELECT COUNT(*) FROM vol
|
||||
INNER JOIN co
|
||||
)
|
||||
|
@ -0,0 +1,315 @@
|
||||
-- 2
|
||||
DO $$
|
||||
DECLARE
|
||||
a INT := 0;
|
||||
b INT := 1;
|
||||
c INT := 1;
|
||||
n INT := 7;
|
||||
BEGIN
|
||||
for i in 2..n loop
|
||||
c = a + b;
|
||||
a = b;
|
||||
b = c;
|
||||
end loop;
|
||||
raise notice '%', c;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 3
|
||||
CREATE OR REPLACE FUNCTION fibonacci(n INT)
|
||||
RETURNS INT AS $$
|
||||
DECLARE
|
||||
a INT := 0;
|
||||
b INT := 1;
|
||||
c INT := 1;
|
||||
BEGIN
|
||||
if n = 0 then
|
||||
return 0;
|
||||
end if;
|
||||
for i in 2..n loop
|
||||
c = a + b;
|
||||
a = b;
|
||||
b = c;
|
||||
end loop;
|
||||
return c;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 4
|
||||
SELECT fibonacci(0); -- 0
|
||||
SELECT fibonacci(1); -- 1
|
||||
SELECT fibonacci(2); -- 1
|
||||
SELECT fibonacci(10); -- 55
|
||||
|
||||
-- 5
|
||||
--DROP FUNCTION IF EXISTS nb_athletes;
|
||||
CREATE OR REPLACE FUNCTION nb_athletes(code_pays pays.code%TYPE)
|
||||
RETURNS INT AS $$
|
||||
BEGIN
|
||||
return (
|
||||
SELECT COUNT(*)
|
||||
FROM athlete
|
||||
WHERE pays = code_pays
|
||||
);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 6
|
||||
SELECT nb_athletes('FRA');
|
||||
|
||||
-- 7
|
||||
SELECT p.code, p.nom
|
||||
FROM athlete a
|
||||
INNER JOIN pays p ON p.code = a.pays
|
||||
GROUP BY p.code
|
||||
HAVING COUNT(*) > nb_athletes('FRA');
|
||||
|
||||
-- 8
|
||||
CREATE OR REPLACE FUNCTION epr(nom_discipline discipline.nom%TYPE, date DATE)
|
||||
RETURNS TABLE (code epreuve.code%TYPE, nom epreuve.nom%TYPE) AS $$
|
||||
BEGIN
|
||||
return query
|
||||
SELECT e.code, e.nom
|
||||
FROM epreuve e
|
||||
WHERE e.discipl = (
|
||||
SELECT d.code FROM discipline d WHERE d.nom = nom_discipline
|
||||
) AND dateE = date;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 9
|
||||
SELECT epr('Athletics', '2021-08-03');
|
||||
|
||||
-- 10
|
||||
UPDATE epreuve SET dateE = dateE+1 WHERE code IN (SELECT code FROM epr('Equestrian', '2021-08-02'));
|
||||
|
||||
-- 11
|
||||
CREATE OR REPLACE FUNCTION pratique(code_athlete athlete.code%TYPE)
|
||||
RETURNS discipline.nom%TYPE AS $$
|
||||
DECLARE
|
||||
res discipline.nom%TYPE;
|
||||
BEGIN
|
||||
SELECT d.nom INTO STRICT res FROM pratiquer p
|
||||
INNER JOIN discipline d ON d.code = p.discipl
|
||||
WHERE p.athlete = code_athlete;
|
||||
return res;
|
||||
EXCEPTION
|
||||
WHEN TOO_MANY_ROWS THEN
|
||||
RAISE EXCEPTION 'L''athlète % pratique plusieurs sports.', code_athlete;
|
||||
WHEN NO_DATA_FOUND THEN
|
||||
RAISE EXCEPTION 'Athlète % inconnu.', code_athlete;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 12
|
||||
SELECT pratique(
|
||||
(
|
||||
SELECT code FROM athlete WHERE prenom = 'Earvin' AND nom = upper('Ngapeth')
|
||||
)
|
||||
);
|
||||
|
||||
-- 13
|
||||
SELECT pratique(
|
||||
(
|
||||
SELECT code FROM athlete WHERE prenom = 'Lotte' AND nom = upper('Kopecky')
|
||||
)
|
||||
);
|
||||
|
||||
-- 14
|
||||
SELECT pratique('B01');
|
||||
|
||||
-- 15
|
||||
CREATE OR REPLACE FUNCTION medailles(code_pays pays.code%TYPE)
|
||||
RETURNS FLOAT AS $$
|
||||
DECLARE
|
||||
total_athletes INT;
|
||||
athletes_medailles INT;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO total_athletes
|
||||
FROM athlete
|
||||
WHERE pays = code_pays;
|
||||
|
||||
IF total_athletes = 0 THEN
|
||||
RAISE EXCEPTION 'Le pays [%] % n''a pas d''athlète.', code_pays, (SELECT nom FROM pays WHERE code = code_pays);
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(DISTINCT r.athlete) INTO athletes_medailles
|
||||
FROM resultat r
|
||||
INNER JOIN athlete a ON a.code = r.athlete
|
||||
WHERE a.pays = code_pays;
|
||||
return athletes_medailles::FLOAT / total_athletes;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 16
|
||||
SELECT medailles(
|
||||
(
|
||||
SELECT code FROM pays WHERE nom = 'France'
|
||||
)
|
||||
);
|
||||
|
||||
-- 17
|
||||
SELECT medailles(
|
||||
(
|
||||
SELECT code FROM pays WHERE nom = 'URSS'
|
||||
)
|
||||
);
|
||||
|
||||
-- 18
|
||||
SELECT p.nom, ROUND((medailles(p.code) * 100)::numeric, 2) medailles
|
||||
FROM resultat r
|
||||
INNER JOIN athlete a ON a.code = r.athlete
|
||||
INNER JOIN pays p ON p.code = a.pays
|
||||
GROUP BY p.code
|
||||
ORDER BY 2 DESC;
|
||||
|
||||
-- 19
|
||||
--DROP FUNCTION IF EXISTS ageMoy_V1;
|
||||
CREATE OR REPLACE FUNCTION ageMoy_V1(code_pays pays.code%TYPE)
|
||||
RETURNS FLOAT AS $$
|
||||
BEGIN
|
||||
return (
|
||||
SELECT AVG(CURRENT_DATE - dateNaiss) / 365.2422
|
||||
FROM athlete
|
||||
WHERE pays = code_pays
|
||||
);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 20
|
||||
/*CREATE OR REPLACE FUNCTION ageMoy_V2(code_pays pays.code%TYPE)
|
||||
RETURNS FLOAT AS $$
|
||||
DECLARE
|
||||
total INT := 0;
|
||||
nb INT := 0;
|
||||
r athlete%rowtype;
|
||||
BEGIN
|
||||
for r in
|
||||
SELECT * FROM athlete WHERE pays = code_pays AND dateNaiss IS NOT NULL
|
||||
loop
|
||||
total = (CURRENT_DATE - r.dateNaiss) + total;
|
||||
nb = nb + 1;
|
||||
end loop;
|
||||
return total::FLOAT / nb / 365.2422;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;*/
|
||||
DROP FUNCTION IF EXISTS ageMoy_V2;
|
||||
CREATE OR REPLACE FUNCTION ageMoy_V2(code_pays pays.code%TYPE)
|
||||
RETURNS FLOAT AS $$
|
||||
DECLARE
|
||||
i INT;
|
||||
fin INT;
|
||||
total INT := 0;
|
||||
nb INT := 0;
|
||||
date_naiss athlete.dateNaiss%TYPE;
|
||||
BEGIN
|
||||
-- Oui.
|
||||
SELECT SUBSTR(MIN(code), 2)::int INTO i FROM athlete WHERE pays = code_pays;
|
||||
SELECT SUBSTR(MAX(code), 2)::int INTO fin FROM athlete WHERE pays = code_pays;
|
||||
|
||||
if i IS NULL then
|
||||
return 0;
|
||||
end if;
|
||||
|
||||
-- Teste pour chaque code possible
|
||||
while i <= fin loop
|
||||
SELECT dateNaiss INTO date_naiss FROM athlete WHERE code = to_char(i, 'FMA00000');
|
||||
if date_naiss IS NOT NULL then
|
||||
total = (CURRENT_DATE - date_naiss) + total;
|
||||
nb = nb + 1;
|
||||
end if;
|
||||
i = i + 1;
|
||||
end loop;
|
||||
|
||||
if nb = 0 then
|
||||
return 0;
|
||||
end if;
|
||||
|
||||
return total::FLOAT / nb / 365.2422;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 21
|
||||
--SELECT ageMoy_V1('FRA') v1, ageMoy_V2('FRA') v2;
|
||||
--SELECT ageMoy_V1('USA') v1, ageMoy_V2('USA') v2;
|
||||
|
||||
-- 22
|
||||
CREATE OR REPLACE FUNCTION ageMoy_V1(code_pays pays.code%TYPE)
|
||||
RETURNS FLOAT AS $$
|
||||
BEGIN
|
||||
return (
|
||||
SELECT COALESCE(AVG(CURRENT_DATE - dateNaiss), 0) / 365.2422
|
||||
FROM athlete
|
||||
WHERE pays = code_pays AND dateNaiss IS NOT NULL
|
||||
);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT ageMoy_V1('') v1, ageMoy_V2('') v2;
|
||||
|
||||
-- 23
|
||||
WITH age_moyen AS (
|
||||
SELECT nom, ageMoy_V1(code) AS age_moyen FROM pays
|
||||
) SELECT nom, age_moyen
|
||||
FROM age_moyen
|
||||
ORDER BY age_moyen DESC
|
||||
LIMIT 1;
|
||||
-- Ou
|
||||
WITH age_moyen AS (
|
||||
SELECT nom, ageMoy_V1(code) AS age_moyen FROM pays
|
||||
) SELECT nom, age_moyen
|
||||
FROM age_moyen
|
||||
WHERE age_moyen = (SELECT MAX(age_moyen) FROM age_moyen);
|
||||
|
||||
-- 24
|
||||
WITH age_moyen AS (
|
||||
SELECT nom, ageMoy_V1(code) AS age_moyen FROM pays
|
||||
) SELECT nom, age_moyen
|
||||
FROM age_moyen
|
||||
WHERE age_moyen != 0
|
||||
ORDER BY age_moyen
|
||||
LIMIT 1;
|
||||
|
||||
-- 25
|
||||
CREATE OR REPLACE FUNCTION gagner(code_athlete athlete.code%TYPE, couleur_medaille medaille.couleur%TYPE)
|
||||
RETURNS INT AS $$
|
||||
BEGIN
|
||||
return (
|
||||
SELECT COUNT(*) FROM resultat WHERE athlete = code_athlete AND medaille = (
|
||||
SELECT place FROM medaille WHERE couleur = couleur_medaille
|
||||
)
|
||||
);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- 26
|
||||
SELECT gagner(
|
||||
(SELECT code FROM athlete WHERE prenom = 'Teddy' AND nom = 'RINER'),
|
||||
'Or'
|
||||
) medailles_or, gagner(
|
||||
(SELECT code FROM athlete WHERE prenom = 'Teddy' AND nom = 'RINER'),
|
||||
'Argent'
|
||||
) medailles_argent, gagner(
|
||||
(SELECT code FROM athlete WHERE prenom = 'Teddy' AND nom = 'RINER'),
|
||||
'Bronze'
|
||||
) medailles_bronze;
|
||||
|
||||
-- 27
|
||||
CREATE TABLE IF NOT EXISTS resultat_fr (
|
||||
code CHAR(6) PRIMARY KEY REFERENCES athlete(code),
|
||||
nom VARCHAR(40) NOT NULL,
|
||||
prenom VARCHAR(40) NOT NULL,
|
||||
dateNaiss DATE,
|
||||
nb_or INT DEFAULT 0,
|
||||
nb_argent INT DEFAULT 0,
|
||||
nb_bronze INT DEFAULT 0
|
||||
);
|
||||
|
||||
-- 28
|
||||
INSERT INTO resultat_fr
|
||||
SELECT code, nom, prenom, dateNaiss, gagner(code, 'Or'), gagner(code, 'Argent'), gagner(code, 'Bronze')
|
||||
FROM athlete
|
||||
WHERE pays = (SELECT code FROM pays WHERE nom = 'France');
|
||||
|
||||
-- 29
|
||||
SELECT * FROM resultat_fr ORDER BY (nb_or + nb_argent + nb_bronze) DESC, dateNaiss;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue