Skip to content

Writing Drone Telemetry to a SQLite Database

Dave Walker edited this page Feb 2, 2020 · 6 revisions

Namespace

The package, library and namespace for SQLite database capture is:

TelloCommander.Data.Sqlite

Prerequisites

Creating the SQLite Database

Prior to capturing data to a SQLite database, you must ensure:

  • The database file has been created
  • The Entity Framework Core migrations have been run to set up the database tables required by the capture

The easiest way to do this is to use a console application to run the migrations:

  • Create a console application that references the TelloCommander and TelloCommanderDb libraries
  • Add an appsettings.json file with the following content:
{
  "ConnectionStrings": {
    "TelloCommanderDb": "Data Source=<path>/tellocommander.db"
  }
}
  • Where path is the path to the folder where you wish the database to be written
  • Set the build action on the "appsettings.json" file to Content
  • Set the "copy to output" property on the "appsettings.json" file to "Always"
  • Add the following using statements to the Program.cs file of the application:
using TelloCommander.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
  • Add the following to the Main() method:
TelloCommanderDbContext context = new TelloCommanderDbContextFactory().CreateDbContext(null);
context.Database.Migrate();
  • Compile and run the application to create the SQLite database at the specified path

Configuring Your Application Settings File

Any application that wishes to use the telemetry database should have an appsettings.json file configured as described above with the "TelloCommanderDb" connection string pointing to a copy of the database created above.

Capturing Telemetry

Please see the information in the Telemetry to SQL Overview page.

Querying the Data

Please see the information in the Telemetry to SQL Overview page.