libdballe
9.11
|
DB-ALLe database connection for database format V7. More...
#include <db.h>
Public Member Functions | |
DB (std::shared_ptr< dballe::sql::Connection > conn) | |
db::Format | format () const override |
Return the format of this DB. | |
v7::Driver & | driver () |
Access the backend DB driver. | |
std::shared_ptr< dballe::Transaction > | transaction (bool readonly=false) override |
Begin a transaction on this database, and return a Transaction object that can be used to commit it. | |
std::shared_ptr< dballe::db::Transaction > | test_transaction (bool readonly=false) override |
Same as transaction(), but the resulting transaction will throw an exception if commit is called. More... | |
void | disappear () override |
Remove all our traces from the database, if applicable. More... | |
void | reset (const char *repinfo_file=0) override |
Reset the database, removing all existing DBALLE tables and re-creating them empty. More... | |
void | delete_tables () |
Delete all the DB-ALLe tables from the database. | |
void | vacuum () override |
Remove orphan values from the database. More... | |
![]() | |
virtual void | attr_query_station (int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest) |
Query attributes on a station value. More... | |
virtual void | attr_query_data (int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest) |
Query attributes on a data value. More... | |
void | attr_insert_station (int data_id, const Values &attrs) |
Insert new attributes on a station value. More... | |
void | attr_insert_data (int data_id, const Values &attrs) |
Insert new attributes on a data value. More... | |
void | attr_remove_station (int data_id, const db::AttrList &attrs) |
Delete attributes from a station value. More... | |
void | attr_remove_data (int data_id, const db::AttrList &attrs) |
Delete attributes from a data value. More... | |
void | dump (FILE *out) |
Dump the entire contents of the database to an output stream. | |
virtual void | print_info (FILE *out) |
Print informations about the database to the given output stream. | |
![]() | |
virtual std::shared_ptr< CursorStation > | query_stations (const Query &query) |
Start a query on the station variables archive. More... | |
virtual std::shared_ptr< CursorStationData > | query_station_data (const Query &query) |
Query the station variables in the database. More... | |
virtual std::shared_ptr< CursorData > | query_data (const Query &query) |
Query the database. More... | |
virtual std::shared_ptr< CursorSummary > | query_summary (const Query &query) |
Query a summary of what the result would be for a query. More... | |
virtual std::shared_ptr< CursorMessage > | query_messages (const Query &query) |
Query the database returning the matching data as Message objects. More... | |
void | remove_all () |
Remove all data from the database. More... | |
void | remove_station_data (const Query &query) |
Remove data from the database. More... | |
void | remove_data (const Query &query) |
Remove data from the database. More... | |
void | import_message (const Message &message, const DBImportOptions &opts=DBImportOptions::defaults) |
Import a Message into the DB-All.e database. More... | |
void | import_messages (const std::vector< std::shared_ptr< Message >> &messages, const DBImportOptions &opts=DBImportOptions::defaults) |
Import Messages into the DB-All.e database. More... | |
void | insert_station_data (Data &vals, const DBInsertOptions &opts=DBInsertOptions::defaults) |
Insert station values into the database. More... | |
void | insert_data (Data &vals, const DBInsertOptions &opts=DBInsertOptions::defaults) |
Insert data values into the database. More... | |
Public Attributes | |
std::shared_ptr< dballe::sql::Connection > | conn |
Database connection. | |
Trace * | trace = nullptr |
Database query tracing. | |
bool | explain_queries = false |
True if we print an EXPLAIN trace of all queries to stderr. | |
Protected Member Functions | |
void | init_after_connect () |
Protected Attributes | |
v7::Driver * | m_driver |
SQL driver backend. | |
Friends | |
class | dballe::DB |
class | dballe::db::v7::Transaction |
Additional Inherited Members | |
![]() | |
static db::Format | get_default_format () |
static void | set_default_format (db::Format format) |
static std::shared_ptr< DB > | connect_from_file (const char *pathname) |
Create from a SQLite file pathname. More... | |
static std::shared_ptr< DB > | connect_memory () |
Create an in-memory database. | |
static std::shared_ptr< DB > | create (std::shared_ptr< sql::Connection > conn) |
Create a database from an open Connection. | |
static bool | is_url (const char *str) |
Return TRUE if the string looks like a DB URL. More... | |
static const char * | default_repinfo_file () |
Return the default repinfo file pathname. | |
static std::unique_ptr< db::DB > | downcast (std::unique_ptr< dballe::DB > db) |
Downcast a unique_ptr pointer. | |
static std::shared_ptr< db::DB > | downcast (std::shared_ptr< dballe::DB > db) |
Downcast a shared_ptr pointer. | |
![]() | |
static std::shared_ptr< DB > | connect (const DBConnectOptions &opts) |
Create a new DB. | |
DB-ALLe database connection for database format V7.
|
overridevirtual |
Remove all our traces from the database, if applicable.
After this has been called, all other DB methods except for reset() will fail.
Implements dballe::db::DB.
|
overridevirtual |
Reset the database, removing all existing DBALLE tables and re-creating them empty.
repinfo_file | The name of the CSV file with the report type information data to load. The file is in CSV format with 6 columns: report code, mnemonic id, description, priority, descriptor, table A category. If repinfo_file is NULL, then the default of /etc/dballe/repinfo.csv is used. |
Implements dballe::db::DB.
|
overridevirtual |
Same as transaction(), but the resulting transaction will throw an exception if commit is called.
Used for tests.
Implements dballe::db::DB.
|
overridevirtual |
Remove orphan values from the database.
Orphan values are currently:
Depending on database size, this routine can take a few minutes to execute.
Implements dballe::db::DB.