Sql2Station¶
This module contains all functions for getting station information from the database and writing it into the database.
Functions and Classes¶
-
getActiveStations(station_ids, station_date=datetime.datetime(2023, 8, 22, 8, 48, 50, 441141), db_conn=None)¶ Function that returns all stations that are active with id in station_ids to the user.
Parameters: - station_ids (Array) – array of ids to be fetched
- station_date (datetime) – date for which the station info will be taken
- db_conn (psycopg2.connection) – Existing connection to the database. Defaults to None
Returns: Dictionary object
-
getAllClosedStations(db_conn=None)¶ Function for getting all closed stations from the database :param psycopg2.connection db_conn: Connection object to the database :returns: Array of Station objects
-
getAllStations(station_date=None, db_conn=None)¶ Function for reading all stations from database. If None is passed as station_date, the function will fetch all station information in the database which will include all closed stations and sitechans.
Parameters: - db_conn (psycopg2.connection) – Connection to the database
- station_date (datetime) – date for which the station info will be taken
Returns: Array of Station objects
-
getStation(station_id, station_date=datetime.datetime(2023, 8, 22, 8, 48, 50, 441150), db_conn=None)¶ Function for reading a station from database by id or code and datetime.
Parameters: Returns: Station object
-
getStationCodes(db_conn=None)¶ Function for reading all station_codes from the database.
Parameters: db_conn (psycopg2.connection) – Connection object to the database Returns: Array of strings
-
getStations(station_ids, station_date=datetime.datetime(2023, 8, 22, 8, 48, 50, 441149), db_conn=None)¶ Function that returns all stations with id in station_ids to the user.
Parameters: - station_ids (Array) – array of ids to be fetched
- station_date (datetime) – date for which the station info will be taken
- db_conn (psycopg2.connection) – Existing connection to the database. Defaults to None
-
getStationsNearPoint(latitude, longitude, radius=10.0, station_date=datetime.datetime(2023, 8, 22, 8, 48, 50, 441151), db_conn=None)¶ Function for getting all stations that are less than radius away from point (latitude, longitude) radius is in kilometers.
Parameters: - latitude (float) – latitude of the point
- lognitude (float) – longitude of the point
- radius (float) – maximum radius allowed by the program in kilometers. Defaults to 10.0 km
- station_date (datetime) – date for the station fetching. Defaults to this date
- db_conn (psycopg2.connection) – Existing connection to the database. Defaults to None