Performing queries with the BearDB REST Server

The BearDB REST Server support SQL Queries and Inserts. A REST client can lookup data using a SELECT query or can insert one row of data into a specific table.

Using BearDB REST Server to SELECT data

BearDB support two forms of REST requests which represent a SELECT query.
The first form is known as a REST Query, where the parameters in the REST request are parsed to determine the table to be selected, and the WHERE clause for the selected records.

The second form allows a regular SQL SELECT statement to be included with the REST request. This form allows the use of any valid SELECT or DESCRIBE statement to be executed, including using Joins, Aggregate operations, and SQL Functions.

Creating a SQL SELECT Query

To create a proper SQL query for the BearDB REST Server, the following settings should be used for the REST request:

    REST Operation: GET
    REST URL: [server]:[port]/beardb/rest/table/query
    HTTP Parameter: sql=[sql select or describe query]

The complete HTTP request is the following:

GET server:port/beardb/rest/table/query?sql=Select%20%2A%20from%20myTestTable

This is the SQL query which will be executed:

    SELECT * FROM myTestTable

Notes on using a SQL Query:
  • The query can only be a SELECT query or a DESCRIBE query. Attempting to put an INSERT, DELETE, CREATE USER, or ALTER statement as the SQL query will result in an error in the response, and the SQL query will not be executed.
  • It is accpetable to use any valid SQL query, including JOINS, Aggregates and the use of SQL Functions.
  • It is not required to use all columns (SELECT *) in a SQL query.
  • If the SQL Query is not valid then there will be a specific error in the response, and the query will not be performed.