diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 00040c1..5598d9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,9 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace + - id: check-yaml + - id: check-toml + - id: check-added-large-files - repo: https://github.com/psf/black rev: 22.6.0 hooks: diff --git a/aukpy/create_tables.sql b/aukpy/create_tables.sql index a9c4662..19ff685 100644 --- a/aukpy/create_tables.sql +++ b/aukpy/create_tables.sql @@ -6,6 +6,8 @@ CREATE TABLE IF NOT EXISTS location_data ( state_code text, county text, county_code text, + longitude float, + latitude float, locality text, locality_id integer, locality_type text, @@ -13,7 +15,7 @@ CREATE TABLE IF NOT EXISTS location_data ( atlas_block text, bcr_code integer, iba_code text, - UNIQUE(country, country_code, state, state_code, county, county_code, locality, locality_id, locality_type, usfws_code, atlas_block) + UNIQUE(country, state, county, locality_id, usfws_code, atlas_block, longitude, latitude) ); CREATE TABLE IF NOT EXISTS bcrcode (id integer PRIMARY KEY, bcr_code text, UNIQUE(bcr_code)); @@ -63,8 +65,6 @@ CREATE TABLE IF NOT EXISTS sampling_event ( effort_area_ha float, duration_minutes integer, trip_comments text, - latitude float, - longitude float, all_species_reported integer, number_observers integer, UNIQUE(sampling_event_identifier) diff --git a/aukpy/db.py b/aukpy/db.py index 63759a1..9bb7859 100644 --- a/aukpy/db.py +++ b/aukpy/db.py @@ -229,6 +229,8 @@ class LocationWrapper(TableWrapper): "state_code", "county", "county_code", + "longitude", + "latitude", "locality", "locality_id", "locality_type", @@ -238,9 +240,17 @@ class LocationWrapper(TableWrapper): "iba_code", ) insert_query = """INSERT OR IGNORE INTO location_data - ('country', 'country_code', 'state', 'state_code', 'county', 'county_code', 'locality', 'locality_id', 'locality_type', 'usfws_code', 'atlas_block', 'bcr_code', 'iba_code') - VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""" - unique_columns = ("country", "state", "county", "locality_id", "atlas_block") + ('country', 'country_code', 'state', 'state_code', 'county', 'county_code', 'longitude', 'latitude', 'locality', 'locality_id', 'locality_type', 'usfws_code', 'atlas_block', 'bcr_code', 'iba_code') + VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""" + unique_columns = ( + "country", + "state", + "county", + "locality_id", + "atlas_block", + "longitude", + "latitude", + ) @classmethod def df_processing(cls, df: pd.DataFrame) -> pd.DataFrame: @@ -300,14 +310,12 @@ class SamplingWrapper(TableWrapper): "effort_area_ha", "duration_minutes", "trip_comments", - "latitude", - "longitude", "all_species_reported", "number_observers", ) insert_query = """INSERT OR IGNORE INTO sampling_event - (sampling_event_identifier, observation_date, time_observations_started, observer_id, effort_distance_km, effort_area_ha, duration_minutes, trip_comments, latitude, longitude, all_species_reported, number_observers) - VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + (sampling_event_identifier, observation_date, time_observations_started, observer_id, effort_distance_km, effort_area_ha, duration_minutes, trip_comments, all_species_reported, number_observers) + VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """ unique_columns = ("sampling_event_identifier",) diff --git a/aukpy/queries.py b/aukpy/queries.py index 7422e7b..8eb7f5c 100644 --- a/aukpy/queries.py +++ b/aukpy/queries.py @@ -8,7 +8,6 @@ Iterable, List, Optional, - Sequence, Union, Tuple, Any,