Interface IDataSourceQueryService


public interface IDataSourceQueryService
A service that supports executing queries on a data source configured in the DSS service.properties.

Jython usage example:

 results = query_service.select("data-source-name", "SELECT * FROM table_name WHERE id > 1") 
 [... do stuff with results]
 results.close()
 

If you need to do this frequently, you may want to extract this into a function

 def execute_query(query_service, block, query, params=None):
     if params is None:
         result = query_service.select("data-source-name", query)
     else:
         result = query_service.select("data-source-name", query, params)
     block(result)
     result.close()
 
  • Method Summary

    Modifier and Type
    Method
    Description
    net.lemnik.eodsql.DataSet<Map<String,Object>>
    select(String dataSourceName, String query)
    Execute a query against the data source with the specified name.
    net.lemnik.eodsql.DataSet<Map<String,Object>>
    select(String dataSourceName, String query, Object... parameters)
    Execute a query against the data source with the specified name.
  • Method Details

    • select

      net.lemnik.eodsql.DataSet<Map<String,Object>> select(String dataSourceName, String query) throws IllegalArgumentException
      Execute a query against the data source with the specified name.
      Parameters:
      dataSourceName - The name of the data source to query against, as declared in the service.properties file.
      query - The SQL query to execute, possibly including parameters marked by '?{X}' where X is the parameter number.
      Returns:
      A List of Maps with the data. Do not forget to close the result when done!
      Throws:
      IllegalArgumentException
    • select

      net.lemnik.eodsql.DataSet<Map<String,Object>> select(String dataSourceName, String query, Object... parameters) throws IllegalArgumentException
      Execute a query against the data source with the specified name.
      Parameters:
      dataSourceName - The name of the data source to query against, as declared in the service.properties file.
      query - The SQL query to execute, possibly including parameters marked by '?{X}' where X is the parameter number.
      parameters - The values for filling in the query parameters.
      Returns:
      A List of Maps with the data. Do not forget to close the result when done!
      Throws:
      IllegalArgumentException