Commit 8c24a65f authored by Danijel Schorlemmer's avatar Danijel Schorlemmer
Browse files

Beautified two SQL queries

parent 198f715d
Pipeline #38821 passed with stage
in 1 minute and 32 seconds
......@@ -461,10 +461,11 @@ class JapanDatabase(SpatialiteDatabase):
]
# Insert the data to the PopulationDistribution table
sql_statement = (
"INSERT INTO PopulationDistribution (district_id, total, male, "
"female, number_household) VALUES (?, ?, ?, ?, ?)"
)
sql_statement = """
INSERT INTO PopulationDistribution
(district_id, total, male, female, number_household)
VALUES (?, ?, ?, ?, ?)
"""
self.cursor.executemany(sql_statement, population_to_db)
self.connection.commit()
......@@ -474,11 +475,13 @@ class JapanDatabase(SpatialiteDatabase):
# and update the PopulationDistribution table
sql_statement = """
UPDATE PopulationDistribution
SET population_density = Q.density FROM
SET population_density = Q.density
FROM
(
SELECT PopulationDistribution.total/District.area_size AS density,
PopulationDistribution.district_id AS id
FROM PopulationDistribution INNER JOIN District
PopulationDistribution.district_id AS id
FROM PopulationDistribution
INNER JOIN District
ON District.id = PopulationDistribution.district_id
) AS Q
WHERE PopulationDistribution.district_id = Q.id
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment