Class SQLDataSource<T extends Output<T>>

java.lang.Object
org.tribuo.data.columnar.ColumnarDataSource<T>
org.tribuo.data.sql.SQLDataSource<T>
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<DataSourceProvenance>, AutoCloseable, Iterable<Example<T>>, ConfigurableDataSource<T>, DataSource<T>

public class SQLDataSource<T extends Output<T>> extends ColumnarDataSource<T> implements AutoCloseable
A DataSource for loading columnar data from a database and applying FieldProcessors to it. The Connections it creates are closed when the iterator is empty (ie. when hasNext is called and returns false). Calling close() on SQLDatasource itself closes all connections created since close was last called.

N.B. This class accepts raw SQL strings and executes them directly via JDBC. It DOES NOT perform any SQL escaping or other injection prevention. It is the user's responsibility to ensure that SQL passed to this class performs as desired.

  • Constructor Details

    • SQLDataSource

      public SQLDataSource(String sqlString, SQLDBConfig sqlConfig, OutputFactory<T> outputFactory, RowProcessor<T> rowProcessor, boolean outputRequired) throws SQLException
      Constructs a SQLDataSource.
      Parameters:
      sqlString - The SQL query to run.
      sqlConfig - The SQL connection configuration.
      outputFactory - The output factory to use.
      rowProcessor - The row processor to convert the returned rows into examples.
      outputRequired - Is an output required from this source.
      Throws:
      SQLException - If the database could not be read.
  • Method Details