naturtag.storage.client module¶
- class naturtag.storage.client.ObservationDbController(*args, taxon_controller, **kwargs)¶
Bases:
ObservationController- count(username, **params)¶
Get the total number of observations matching the specified criteria from the API
- Return type:
int
- count_db()¶
Get the total number of observations in the local database
- Return type:
int
- from_ids(observation_ids, refresh=False, ident_taxa=False, taxonomy=False, **params)¶
Get observations by ID; first from the database, then from the API
- Return type:
- save(observations)¶
Save observations to the database (full records + text search index)
- search(**params)¶
Search observations, and save results to the database (for future reference by ID)
- Return type:
- search_user(username, updated_since=None, limit=50, page=1)¶
Fetch any new user observations from the API since last search, save them to the db, and then return up to
limitmost recent observations from the db- Return type:
list[Observation]
- search_user_db(username, limit=50, page=1)¶
Read a single page of observations from the local DB, ordered by creation date
- Return type:
list[Observation]
- search_user_paginated(username, updated_since=None, id_above=None)¶
Fetch any new observations from the API since last search, saving and yielding a single page at a time.
- Return type:
Iterator[list[Observation]]
- class naturtag.storage.client.TaxonDbController(client)¶
Bases:
TaxonController- from_ids(taxon_ids, accept_partial=False, refresh=False, **params)¶
Get taxa by ID; first from the database, then from the API
- Return type:
- search(**params)¶
Search taxa, and save results to the database (for future reference by ID)
- Return type:
- class naturtag.storage.client.iNatDbClient(db_path=PosixPath('/home/docs/.local/share/Naturtag/naturtag.db'), **kwargs)¶
Bases:
iNatClientAPI client class that uses a local SQLite database to cache observations and taxa (when searched by ID)
- from_id(observation_id=None, taxon_id=None)¶
Get an iNaturalist observation and/or taxon matching the specified ID(s). If only a taxon ID is provided, the observation will be a placeholder with only the taxon field populated.
- Return type:
Optional[Observation]