sdwis_drink_water.api_for_table
Module Contents
Classes
A class to interact with the SDWIS Table API. |
Attributes
- sdwis_drink_water.api_for_table.log
- class sdwis_drink_water.api_for_table.SdwisTable(enable_cache=True, print_url=False)
A class to interact with the SDWIS Table API.
- _get_data_by_request(query_url, print_to_console=False, multi_threads=False)
Internal method to get data by sending a request to the specified URL.
- Parameters:
query_url (str) – The URL to send the request to.
print_to_console (bool) – Flag to print the result to console.
multi_threads (bool) – Flag to enable multi-threading for the request.
- Returns:
The query result as a list of dictionaries.
- Return type:
list
- _get_result_data_by_request(query_url, print_to_console=False)
Internal method to get data by sending a request to the specified URL.
- Parameters:
query_url (str) – The URL to send the request to.
print_to_console (bool) – Flag to print the result to console.
- Returns:
The query result as a list of dictionaries.
- Return type:
- get_all_table_names(print_to_console=True)
Retrieves all table names from the SDWIS database.
- Parameters:
print_to_console (bool) – Flag to print the table names to console.
- Returns:
A list of all table names.
- Return type:
list
- get_all_table_names_and_descriptions(print_to_console=True)
Retrieves all table names and their descriptions from the SDWIS database.
- Parameters:
print_to_console (bool) – Flag to print the table names and descriptions to console.
- Returns:
A list of table names and descriptions or a dictionary if not printed.
- Return type:
list or dict
- get_table_column_name_by_table_name(table_name='', print_to_console=True)
Retrieves column names for a specified table.
- Parameters:
table_name (str) – Name of the table.
print_to_console (bool) – Flag to print the column names to console.
- Returns:
A list of column names for the specified table.
- Return type:
list
- get_columns_description_by_table_name(table_name='', print_to_console=True, multi_threads=False)
Retrieves descriptions for all columns of a specified table.
- Parameters:
table_name (str) – Name of the table.
print_to_console (bool) – Flag to print column descriptions to console.
multi_threads (bool) – Flag to enable multi threads requests.
- Returns:
A dictionary mapping column names to their descriptions.
- Return type:
dict
- get_table_data_number(table_name='')
Retrieves the number of records in a specified table.
- Parameters:
table_name (str) – Name of the table.
- Returns:
The total number of records in the table.
- Return type:
int
- get_table_first_data_by_table_name(table_name='', print_to_console=True)
Retrieves the first record of a specified table.
- Parameters:
table_name (str) – Name of the table.
print_to_console (bool) – Flag to print the first record to console.
- Returns:
The first record of the table.
- Return type:
dict or ResultDataParser
- get_table_first_n_data_by_table_name(table_name='', n=0, print_to_console=True, multi_threads=False)
Retrieves the first ‘n’ records of a specified table.
- Parameters:
table_name (str) – Name of the table.
n (int) – Number of records to retrieve.
print_to_console (bool) – Flag to print the records to console.
multi_threads (bool) – Flag to enable multi-threading.
- Returns:
A list of the first ‘n’ records from the table.
- Return type:
list or ResultDataParser
- get_data_by_conditions(table_name='', condition1='', condition2='', condition3='', print_to_console=True, only_count=False)
Retrieves data from a table based on specified conditions.
- Parameters:
table_name (str) – Name of the table.
condition1 (str) – Conditions for data retrieval.
condition2 (str) – Conditions for data retrieval.
condition3 (str) – Conditions for data retrieval.
print_to_console (bool) – Flag to print the results to console.
only_count (bool) – Flag to retrieve only the count of matching records.
- Returns:
List of matching records, or count of records if only_count is True.
- Return type:
list or int
- summarize_data_by_epa_region(table_name='', print_to_console=True, multi_threads=False)
Summarizes data by EPA region for a specified table.
- Parameters:
table_name (str) – Name of the table.
print_to_console (bool) – Flag to print summary to console.
multi_threads (bool) – Flag to enable multi-threading.
- Returns:
A list containing the data summary by EPA region.
- Return type:
list
- get_data_by_epa_region(table_name='', epa_region=1, print_to_console=True, only_count=False, multi_mode=False)
Retrieves data from a table filtered by a specific EPA region. SAMPLE URL: https://data.epa.gov/efservice/LCR_SAMPLE/EPA_REGION/=/01/JSON :param table_name: Name of the table. :type table_name: str :param epa_region: EPA region number. :type epa_region: int :param print_to_console: Flag to print the results to console. :type print_to_console: bool :param only_count: Flag to retrieve only the count of records. :type only_count: bool :param multi_mode: Flag to enable multi-threading. :type multi_mode: bool
- Returns:
List of records or count of records if only_count is True.
- Return type:
list or int