Class MDBTable

java.lang.Object
mindsdb.services.Query
mindsdb.models.MDBTable
Direct Known Subclasses:
View

public class MDBTable extends Query
The MDBTable class represents a table in the MindsDB system. It extends the Query class and provides methods to interact with the table, such as filtering, limiting, tracking, inserting, deleting, and updating data.

Example usage:

 
 Database db = server.getDatabase("my_database");
 MDBTable table = db.getTable("my_table");
 table.filter("column1=value1").limit(10).track("column2");
 table.insert(someQuery);
 table.insert(someDataFrame);
 table.delete("column1=value1");
 table.update(Map.of("column1", "new_value"), "column2=value2");
 
 

The class also overrides the toString method to provide a string representation of the MDBTable object.

See Also:
  • Constructor Details

    • MDBTable

      public MDBTable(Database database, String name)
      Create a new Mindsdb Table object
      Parameters:
      database - - Database object
      name - - Name of the table
    • MDBTable

      public MDBTable(Project project, String name)
      Create a new Mindsdb Table object
      Parameters:
      project - - Project object
      name - - Name of the table
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Query
    • filter

      public MDBTable filter(String... filters)
      Filter the table by key-value pairs >>> table.filter("a=1", "b=2") *
      Parameters:
      filters - - Key-value pairs to filter the table by
      Returns:
      Table object with the filters set
    • limit

      public MDBTable limit(Integer limit)
      Limit the number of rows returned by the query
      Parameters:
      limit - - Number of rows to limit the query to
      Returns:
      Table object with the limit set
    • track

      public MDBTable track(String column)
      Track the table by a column
      Parameters:
      column - - Column to track the table by
      Returns:
      Table object with the track column set
    • insert

      public void insert(Query query)
      Insert data into table
      Parameters:
      query - a Query object representing the data to insert
    • insert

      public void insert(tech.tablesaw.api.Table query)
      Insert data into table
      Parameters:
      query - a Tablesaw Table object representing the data to insert
    • delete

      public void delete(String... filters)
      Deletes record from table using filters >>> table.delete("a=1", "b=2")
      Parameters:
      filters - array of filters to filter deleted rows, delete("column=value", ...)
    • update

      public void update(Map<String,Object> values, String... filters)
      Update table by condition
      Parameters:
      values - a map representing fields to update
      filters - array of filters to filter updated rows, update(values, "column=value", ...)
    • update

      public void update(Query value, List<String> on)
      Update table by condition
      Parameters:
      value - a Query object representing the data to update
      on - array of the columns to update on