Add --year parameter
This commit is contained in:
parent
ae463b854e
commit
d1ea569bcd
1 changed files with 10 additions and 5 deletions
|
@ -33,6 +33,11 @@ def parse_args():
|
||||||
default='.pgconn'
|
default='.pgconn'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument('--year',
|
||||||
|
help='Specify year needed to display statistics',
|
||||||
|
choices=['1982', '1990', '1999', '2008', '2013', '2018'],
|
||||||
|
default=2018
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument('--schema-name',
|
parser.add_argument('--schema-name',
|
||||||
help='Database schema name',
|
help='Database schema name',
|
||||||
|
@ -101,7 +106,7 @@ if __name__ == '__main__':
|
||||||
INNER JOIN %(schema)s.departement d ON c.dep = d.dep
|
INNER JOIN %(schema)s.departement d ON c.dep = d.dep
|
||||||
WHERE d.reg = %(state)s
|
WHERE d.reg = %(state)s
|
||||||
""",
|
""",
|
||||||
{'state': s_id, 'schema': AsIs(args.schema_name)}
|
{'state': s_id, 'schema': AsIs(args.schema_name), 'tear': args.year }
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
surface = cur.fetchone()
|
surface = cur.fetchone()
|
||||||
|
@ -119,10 +124,10 @@ if __name__ == '__main__':
|
||||||
INNER JOIN %(schema)s.departement d ON c.dep = d.dep
|
INNER JOIN %(schema)s.departement d ON c.dep = d.dep
|
||||||
INNER JOIN %(schema)s.statistique s ON c.com = s.com
|
INNER JOIN %(schema)s.statistique s ON c.com = s.com
|
||||||
WHERE s.id_indicateur = 1
|
WHERE s.id_indicateur = 1
|
||||||
AND s.date_debut = 2018
|
AND s.date_debut = %(year)s
|
||||||
AND d.reg = %(state)s;
|
AND d.reg = %(state)s;
|
||||||
""",
|
""",
|
||||||
{'state': s_id, 'schema': AsIs(args.schema_name)}
|
{'state': s_id, 'schema': AsIs(args.schema_name), 'year': args.year}
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
inhabitants = cur.fetchone()
|
inhabitants = cur.fetchone()
|
||||||
|
@ -142,12 +147,12 @@ if __name__ == '__main__':
|
||||||
INNER JOIN %(schema)s.departement d ON c.dep = d.dep
|
INNER JOIN %(schema)s.departement d ON c.dep = d.dep
|
||||||
INNER JOIN %(schema)s.statistique s ON c.com = s.com
|
INNER JOIN %(schema)s.statistique s ON c.com = s.com
|
||||||
WHERE s.id_indicateur = 1
|
WHERE s.id_indicateur = 1
|
||||||
AND s.date_debut = 2018
|
AND s.date_debut = %(year)s
|
||||||
AND d.reg = %(state)s
|
AND d.reg = %(state)s
|
||||||
ORDER BY s.valeur DESC
|
ORDER BY s.valeur DESC
|
||||||
LIMIT 10;
|
LIMIT 10;
|
||||||
""",
|
""",
|
||||||
{'state': s_id, 'schema': AsIs(args.schema_name)}
|
{'state': s_id, 'schema': AsIs(args.schema_name), 'year': args.year}
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
towns = cur.fetchall()
|
towns = cur.fetchall()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue