/cpp-sqlite-db-adapter

Implementation of C++ DB adapter based on SQLite

Primary LanguageC++

Build Status Build status codecov Codacy Badge

C++ Database Adapter implementation with SQLite

This repository implements the interface for the C++ Database Adapter using SQLite.

Setup

Download using Conan

This library is designed to be installed by making use of Conan package manager. So, you just need to add the following requirement into your Conan recipe:

def requirements(self):
   self.requires("DbSQLiteAdapter/1.0.0@systelab/stable")

Version number of this code snipped is set just as an example. Replace it for the desired version package to retrieve.

As this package is not available on the conan-center, you will also need to configure a remote repository before installing dependencies:

conan remote add systelab-public https://csw.jfrog.io/artifactory/api/conan/cpp-conan-production-local

See Conan documentation for further details on how to integrate this package with your build system.

Build from sources

See BUILD.md document for details.

Usage

Establish connection to a SQLite database by creating a configuration object that specifies the path of .db file to open:

#include "DbSQLiteAdapter/Connection.h"
#include "DbSQLiteAdapter/ConnectionConfiguration.h"

systelab::db::sqlite::Connection connection;
systelab::db::sqlite::ConnectionConfiguration configuration("MyFolder/MyDatabase.db");
std::unique_ptr<systelab::db::IDatabase> database = connection.loadDatabase(configuration);

Use the created systelab::db::IDatabase object to access to the database as described on C++ Database Adapter documentation.

Encryption

In order work with encryption, the connection configuration object must include a key as the second attribute:

systelab::db::sqlite::Connection connection;
systelab::db::sqlite::ConnectionConfiguration configuration("MyFolder/MyDatabase.db", "Y0urDBEncrypt1onK3y");
std::unique_ptr<systelab::db::IDatabase> database = connection.loadDatabase(configuration);