#include <SQLiteDatabase.h>
A basic class for performing basic SQLite database operations. This the boilerplate code used to manage the SQLiteDatabase. This database is not thread-safe, and must be protected before being used in a mutlithreaded fashion.
◆ SQLiteDatabase()
alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::SQLiteDatabase |
( |
const std::string & |
filePath | ) |
|
Constructor. The internal variables are initialized.
- Parameters
-
filePath | The location of the file that the SQLite DB will use as it's backing storage when initialize or open are called. |
◆ ~SQLiteDatabase()
alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::~SQLiteDatabase |
( |
| ) |
|
Destructor.
On destruction, the DB is checked to see if it is closed. It must be closed before the SQLiteDatabase object is destroyed as there is no handle to the DB to close it after this object is gone.
◆ beginTransaction()
std::unique_ptr<Transaction> alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::beginTransaction |
( |
| ) |
|
Begins transaction.
- Returns
- true if query succeeded, false otherwise
◆ clearTable()
bool alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::clearTable |
( |
const std::string & |
tableName | ) |
|
Remove all the rows from the specified table.
- Parameters
-
tableName | The name of the table to clear. |
- Returns
- true if successful, false if there was an error.
◆ close()
void alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::close |
( |
| ) |
|
If open, close the internal SQLite DB. Do nothing if there is no DB open.
◆ createStatement()
std::unique_ptr<SQLiteStatement> alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::createStatement |
( |
const std::string & |
sqlString | ) |
|
Create an SQLiteStatement object to execute the provided string.
- Parameters
-
sqlString | The SQL command to execute. |
- Returns
- A unique_ptr to the SQLiteStatement that represents the sqlString.
◆ dropTable()
bool alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::dropTable |
( |
const std::string & |
tableName | ) |
|
Drops specified table.
This method drops the table if it exists and is empty.
- Parameters
-
tableName | The name of the table to drop. |
- Returns
- true if successful, false if there was an error.
◆ initialize()
bool alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::initialize |
( |
| ) |
|
The internal SQLite DB is created.
- Returns
- true, if the (empty) DB is created successfully. If there is already a DB at the path specified, this function fails and returns false. It also returns false if the database is already opened or if there is an internal failure in creating the DB.
◆ isDatabaseReady()
bool alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::isDatabaseReady |
( |
| ) |
|
Checks if the database is ready to be acted upon.
- Returns
- true if database is ready to be acted upon, false otherwise.
◆ open()
bool alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::open |
( |
| ) |
|
The internal SQLite DB is opened.
- Returns
- true, if the DB is opened successfully. If there is no DB at the path specified, this function fails and returns false. It also returns false if the database is already opened or if there is an internal failure in creating the DB.
◆ performQuery()
bool alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::performQuery |
( |
const std::string & |
sqlString | ) |
|
Run a SQL query on the database.
- Parameters
-
sqlString | A valid SQL query. |
- Returns
- true if successful, false if there is a problem.
◆ tableExists()
bool alexaClientSDK::storage::sqliteStorage::SQLiteDatabase::tableExists |
( |
const std::string & |
tableName | ) |
|
Check to see if a specified table exists.
- Parameters
-
tableName | The name of the table to check. |
- Returns
- true if the table exists, flase if it doesn't or there is an error.
The documentation for this class was generated from the following file:
- /workplace/avs-device-sdk/Storage/SQLiteStorage/include/SQLiteStorage/SQLiteDatabase.h
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0