Skip to content

Commit 7ee97a5

Browse files
committed
Deal with missing gambia
1 parent 912fd2f commit 7ee97a5

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

flowdb/testdata/bin/migrate_synth_data.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,22 @@ def do_exec(args):
173173
174174
INSERT INTO geography.geoms (short_name, long_name, geo_kind_id, spatial_resolution, geom)
175175
SELECT admin0pcod as short_name, admin0name as long_name, 1 as geo_kind_id, 0 as spatial_resolution, geom
176-
FROM geography.admin0;
177-
178-
INSERT INTO geography.geoms (short_name, long_name, geo_kind_id, spatial_resolution, geom)
179-
SELECT district_c as short_name, district_n as long_name, 1 as geo_kind_id, 2 as spatial_resolution, geom
180-
FROM public.gambia_admin2;
181-
182-
/* Populate the geobridge */
183-
184-
INSERT INTO geography.geo_bridge (location_id, gid, valid_from, valid_to, linkage_method_id)
176+
FROM geography.admin0;"""
177+
)
178+
with engine.begin() as trans:
179+
try:
180+
trans.execute(
181+
"""
182+
INSERT INTO geography.geoms (short_name, long_name, geo_kind_id, spatial_resolution, geom)
183+
SELECT district_c as short_name, district_n as long_name, 1 as geo_kind_id, 2 as spatial_resolution, geom
184+
FROM public.gambia_admin2;"""
185+
)
186+
except:
187+
pass # No gambia table
188+
with engine.begin() as trans:
189+
# Populate the geobridge
190+
trans.execute(
191+
"""INSERT INTO geography.geo_bridge (location_id, gid, valid_from, valid_to, linkage_method_id)
185192
SELECT locations.location_id, geoms.gid, '-Infinity'::date as valid_from, 'Infinity'::date as valid_to, 1 as linkage_method_id from interactions.locations LEFT JOIN geography.geoms ON ST_Intersects(position, geom);
186193
"""
187194
)

0 commit comments

Comments
 (0)