#include <SQLiteDatabase.hpp>
Inherits pion::platform::Database.
Definition at line 39 of file SQLiteDatabase.hpp.
Public Member Functions | |
| SQLiteDatabase (void) | |
| virtual | ~SQLiteDatabase () |
| virtual destructor: this class is meant to be extended | |
| virtual pion::platform::DatabasePtr | clone (void) const |
| virtual void | open (unsigned partition=0) |
| virtual void | close (void) |
| closes the database connection | |
| std::string | dbPartition (std::string name, unsigned partition) |
| Produce database name, based on table name, and partition#. | |
| virtual boost::uint64_t | getCache (CACHEPARAM what) |
| get various database related configuration parameters | |
| virtual bool | is_open (void) const |
| returns true if the database connection is open | |
| virtual void | runQuery (const std::string &sql_query, const boost::regex &suppress) |
| virtual pion::platform::QueryPtr | addQuery (pion::platform::QueryID query_id, const std::string &sql_query) |
| virtual void | createTable (const pion::platform::Query::FieldMap &field_map, std::string &table_name, const pion::platform::Query::IndexMap &index_map, unsigned partition) |
| virtual void | dropTable (std::string &table_name, unsigned partition=0) |
| virtual bool | tableExists (std::string &table_name, unsigned partition=0) |
| virtual pion::platform::QueryPtr | prepareInsertQuery (const pion::platform::Query::FieldMap &field_map, const std::string &table_name) |
| virtual pion::platform::QueryPtr | prepareInsertIgnoreQuery (const pion::platform::Query::FieldMap &field_map, const std::string &table_name) |
| virtual pion::platform::QueryPtr | prepareFullQuery (const std::string &query, const boost::regex &suppress) |
| virtual pion::platform::QueryPtr | getBeginTransactionQuery (void) |
| virtual pion::platform::QueryPtr | getCommitTransactionQuery (void) |
| virtual void | setConfig (const pion::platform::Vocabulary &v, const xmlNodePtr config_ptr) |
Static Public Member Functions | |
| static void | throwAPIException (sqlite3 *db_ptr) |
Protected Member Functions | |
| std::string | getSQLiteError (void) |
| returns a string containing the SQLite API error message | |
Classes | |
| class | DBStillOpen |
| exception thrown if the the SQLite API returns an unexpected result More... | |
| class | EmptyFilenameException |
| exception thrown if the SQLiteDatabase configuration does not define a Filename More... | |
| class | SQLiteAPIException |
| exception thrown if the the SQLite API returns an unexpected result More... | |
| class | SQLiteQuery |
| pion::plugins::SQLiteDatabase::SQLiteDatabase | ( | void | ) | [inline] |
constructs a new SQLiteDatabase object
Definition at line 71 of file SQLiteDatabase.hpp.
Referenced by clone().
| QueryPtr pion::plugins::SQLiteDatabase::addQuery | ( | pion::platform::QueryID | query_id, | |
| const std::string & | sql_query | |||
| ) | [virtual] |
adds a compiled SQL query to the database
| query_id | string used to uniquely identify the type of query | |
| sql_query | SQL query to compile and cache for later use |
Implements pion::platform::Database.
Definition at line 147 of file SQLiteDatabase.cpp.
References is_open(), and pion::platform::Database::m_query_map.
Referenced by getBeginTransactionQuery(), getCommitTransactionQuery(), prepareInsertIgnoreQuery(), and prepareInsertQuery().
| DatabasePtr pion::plugins::SQLiteDatabase::clone | ( | void | ) | const [virtual] |
clones the Database, returning a pointer to the cloned copy
Implements pion::platform::Database.
Definition at line 56 of file SQLiteDatabase.cpp.
References pion::platform::Database::copyDatabase(), m_database_name, and SQLiteDatabase().
| void pion::plugins::SQLiteDatabase::createTable | ( | const pion::platform::Query::FieldMap & | field_map, | |
| std::string & | table_name, | |||
| const pion::platform::Query::IndexMap & | index_map, | |||
| unsigned | partition | |||
| ) | [virtual] |
creates a database table for output, if it does not already exist
| field_map | mapping of Vocabulary Terms to Database fields | |
| table_name | name of the table to create | |
| index_map | table of indexes, matches field_map | |
| partition | optional partition number (default 0 = no partition) |
Implements pion::platform::Database.
Definition at line 165 of file SQLiteDatabase.cpp.
References dbPartition(), getSQLiteError(), is_open(), pion::platform::Database::m_create_log, pion::platform::Database::m_create_log_attr, pion::platform::Database::m_sql_affinity, runQuery(), and pion::platform::Database::stringSubstitutes().
| void pion::plugins::SQLiteDatabase::dropTable | ( | std::string & | table_name, | |
| unsigned | partition = 0 | |||
| ) | [virtual] |
drops table, fastest way
| table_name | name of the table to drop | |
| partition | optional partition number |
Implements pion::platform::Database.
Definition at line 265 of file SQLiteDatabase.cpp.
References close(), dbPartition(), and open().
| QueryPtr pion::plugins::SQLiteDatabase::getBeginTransactionQuery | ( | void | ) | [virtual] |
returns the query that is used to begin new transactions
Implements pion::platform::Database.
Definition at line 328 of file SQLiteDatabase.cpp.
References addQuery(), pion::platform::Database::BEGIN_QUERY_ID, is_open(), pion::platform::Database::m_begin_insert, and pion::platform::Database::m_query_map.
| QueryPtr pion::plugins::SQLiteDatabase::getCommitTransactionQuery | ( | void | ) | [virtual] |
returns the query that is used to end and commit transactions
Implements pion::platform::Database.
Definition at line 337 of file SQLiteDatabase.cpp.
References addQuery(), pion::platform::Database::COMMIT_QUERY_ID, is_open(), pion::platform::Database::m_commit_insert, and pion::platform::Database::m_query_map.
| void pion::plugins::SQLiteDatabase::open | ( | unsigned | partition = 0 |
) | [virtual] |
opens the database connection
| create_backup | if true, create a backup of the old database before opening |
Implements pion::platform::Database.
Definition at line 64 of file SQLiteDatabase.cpp.
References dbPartition(), getSQLiteError(), and pion::platform::Database::m_pre_sql.
Referenced by dropTable().
| QueryPtr pion::plugins::SQLiteDatabase::prepareFullQuery | ( | const std::string & | query, | |
| const boost::regex & | suppress | |||
| ) | [virtual] |
prepares a generic query
| query | the SQL for the query | |
| suppress | regex containing pattern of suppressable errors |
Implements pion::platform::Database.
Definition at line 346 of file SQLiteDatabase.cpp.
References is_open().
| QueryPtr pion::plugins::SQLiteDatabase::prepareInsertQuery | ( | const pion::platform::Query::FieldMap & | field_map, | |
| const std::string & | table_name | |||
| ) | [virtual] |
prepares the query that is used to insert events
| field_map | mapping of Vocabulary Terms to Database fields | |
| table_name | name of the table to insert events into |
Implements pion::platform::Database.
Definition at line 292 of file SQLiteDatabase.cpp.
References addQuery(), pion::platform::Database::INSERT_QUERY_ID, is_open(), pion::platform::Database::m_insert_log, pion::platform::Database::m_query_map, and pion::platform::Database::stringSubstitutes().
| void pion::plugins::SQLiteDatabase::runQuery | ( | const std::string & | sql_query, | |
| const boost::regex & | suppress | |||
| ) | [virtual] |
runs a simple query, ignoring any results returned
| sql_query | SQL query to execute | |
| suppress | Regex to describe what errors/exceptions to suppress |
Implements pion::platform::Database.
Definition at line 136 of file SQLiteDatabase.cpp.
References getSQLiteError(), and is_open().
Referenced by createTable().
| void pion::plugins::SQLiteDatabase::setConfig | ( | const pion::platform::Vocabulary & | v, | |
| const xmlNodePtr | config_ptr | |||
| ) | [virtual] |
sets configuration parameters for this Database
| v | the Vocabulary that this Database will use to describe Terms | |
| config_ptr | pointer to a list of XML nodes containing Database configuration parameters |
Reimplemented from pion::platform::Database.
Definition at line 42 of file SQLiteDatabase.cpp.
References pion::platform::PlatformPlugin::getDatabaseManager(), pion::platform::PlatformPlugin::getId(), pion::platform::Database::readConfig(), and pion::platform::ConfigManager::resolveRelativeDataPath().
| bool pion::plugins::SQLiteDatabase::tableExists | ( | std::string & | table_name, | |
| unsigned | partition = 0 | |||
| ) | [virtual] |
table exists?
| table_name | name of the table to drop | |
| partition | optional partition number |
Implements pion::platform::Database.
Definition at line 283 of file SQLiteDatabase.cpp.
References dbPartition().
| static void pion::plugins::SQLiteDatabase::throwAPIException | ( | sqlite3 * | db_ptr | ) | [inline, static] |
throws an API exception using the most recent log message set for a database
| db_ptr | pointer to a SQLite database to use |
Definition at line 238 of file SQLiteDatabase.hpp.
Referenced by pion::plugins::SQLiteDatabase::SQLiteQuery::bindBigInt(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindBlob(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindDate(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindDateTime(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindDouble(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindFloat(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindInt(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindLongDouble(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindNull(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindString(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindTime(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindUBigInt(), pion::plugins::SQLiteDatabase::SQLiteQuery::bindUInt(), pion::plugins::SQLiteDatabase::SQLiteQuery::fetchRow(), pion::plugins::SQLiteDatabase::SQLiteQuery::run(), and pion::plugins::SQLiteDatabase::SQLiteQuery::SQLiteQuery().
1.4.7