Skip to content
Snippets Groups Projects
Commit 61aafc8e authored by Riccardo Boero's avatar Riccardo Boero :innocent:
Browse files

Table optimization test.

parent 0422ff4c
No related branches found
No related tags found
No related merge requests found
name = "FACT_data_API_reader" name = "FACT_data_API_reader"
uuid = "77ed0678-dbc6-4e3d-9156-895052ddb5a7" uuid = "77ed0678-dbc6-4e3d-9156-895052ddb5a7"
authors = ["Riccardo Boero <ribo@nilu.no>"] authors = ["Riccardo Boero <ribo@nilu.no>"]
version = "0.0.5" version = "0.0.6"
[deps] [deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
......
...@@ -85,8 +85,10 @@ function us_air(conn_dict::Dict, selection::Dict) ...@@ -85,8 +85,10 @@ function us_air(conn_dict::Dict, selection::Dict)
dftemp = DataFrame() dftemp = DataFrame()
# iterate over geo objects # iterate over geo objects
for (id, shape) in zip(geo_id, shape_obj) for (id, shape) in zip(geo_id, shape_obj)
# Extract the first two characters of id in Julia
id_short = id[1:2]
# prepare query # prepare query
query = "SELECT count(*) as airports, SUM(COALESCE(COMMERCIAL, 0) + COALESCE(COMMUTER_O, 0) + COALESCE(AIR_TAXI_O, 0) + COALESCE(LOCAL_OPS, 0) + COALESCE(ITNRNT_OPS, 0) + COALESCE(MIL_ACFT_O, 0)) as flights FROM us_airports WHERE fips_state = '"*id*"' AND ST_Intersects(ST_GeomFromText('"*shape*"'), SHAPE);" query = "SELECT count(*) as airports, SUM(COALESCE(COMMERCIAL, 0) + COALESCE(COMMUTER_O, 0) + COALESCE(AIR_TAXI_O, 0) + COALESCE(LOCAL_OPS, 0) + COALESCE(ITNRNT_OPS, 0) + COALESCE(MIL_ACFT_O, 0)) as flights FROM us_airports WHERE fips_state = '"*id_short*"' AND ST_Intersects(ST_GeomFromText('"*shape*"'), SHAPE);"
# create connection # create connection
conn = establish_connection(conn_dict["host"], conn_dict["user"], conn_dict["password"], conn_dict["database"]; port=conn_dict["port"]) conn = establish_connection(conn_dict["host"], conn_dict["user"], conn_dict["password"], conn_dict["database"]; port=conn_dict["port"])
# execute # execute
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment