LiteDB: Looking Up Database and Writing Queries

By using a LiteDBConnection and LiteDBStatement objects, you can access and manage a database file stored in a device that operates an app. The foregoing two objects allow you to look up data and write queries when a certain database object is selected.

Look up database

After setting a database file as a value of the datasource property of a LiteDBConnection object, double-click the object icon of the database. Then, a new tab page will open to provide you with the information on the database. You can do the same job by opening the context menu from the icon and selecting Edit.

Follow the below link to download the database file used as a sample in this chapter. After saving the file to a project folder or another appropriate directory, set the file as a value of the datasource property.

nexacro_sample_db.sqlite

When you select a table, you can see the CREATE TABLE query on the right panel. If you expand a table in the tree view, you can see the columns included by the table. You can select and copy a query but cannot edit it.

If you select the Data tab at the bottom of the right pane, you can see the data of the selected table.

If the database includes indexes, triggers and views, you can also see the relevant information.

Write queries

After setting a LiteDBConnection object as a value of the ldbconnection property of a LiteDBStatement object, double-click the icon of the LiteDBStatement to open the Query Editor. You can do the same job by opening the context menu from the icon and selecting Edit.

You can write queries on the editor or load a query file that contains existing queries.

Written queries can be applied as a value of the query property of the LiteDBStatement. If you block-select a certain portion, only the block will be a value of query.

Standard Bar

Menu item

Description

Save Query

Applies written queries as a value of the query property.

(If you block-select a certain portion, only the block will be applied.)

Load Query File

Loads a query file that contains existing queries.

Save Query File

Save written queries as a file.

You can separately define parameters used for writing queries. Set the value of the parameters property as presented below. If you add a parameter in the format like :POS_CD to a query statement, the parameters defined by the parameters property will be used when the query is executed.