This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import getpass | |
import psycopg2 | |
import psycopg2.extras | |
def select_one(sql_raw, params): | |
""" Runs SELECT query that will return zero or 1 rows. `params` is required.""" | |
return _execute_query(sql_raw, params, 'sel_single') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE VIEW public.srid_units AS | |
SELECT srid, CASE WHEN proj4text LIKE '%+units=%' THEN True | |
ELSE False | |
END AS units_set, | |
CASE WHEN proj4text LIKE '%+units=m%' THEN 'Meters' | |
WHEN proj4text LIKE '%+units=ft%' THEN 'Feet' | |
WHEN proj4text LIKE '%+units=us-ft%' THEN 'Feet' | |
WHEN proj4text LIKE '%+units=link%' | |
OR proj4text LIKE '%+units=%' | |
THEN 'Set, not caught properly' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE EXTENSION IF NOT EXISTS file_fdw; | |
CREATE EXTENSION IF NOT EXISTS postgis; | |
CREATE SERVER fdw_files FOREIGN DATA WRAPPER file_fdw; | |
CREATE FOREIGN TABLE public.fdw_us_state_bbox | |
( | |
id INT, | |
fips TEXT, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS p_group; | |
CREATE TABLE p_group | |
( | |
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, | |
osm_date DATE NOT NULL, | |
region TEXT NOT NULL, | |
CONSTRAINT uq_p_group UNIQUE (osm_date, region) | |
); | |
INSERT INTO p_group (osm_date, region) |