libdballe  9.11
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
dballe::db::v7::DB Class Reference

DB-ALLe database connection for database format V7. More...

#include <db.h>

Inheritance diagram for dballe::db::v7::DB:
dballe::db::DB dballe::DB

Public Member Functions

 DB (std::shared_ptr< dballe::sql::Connection > conn)
 
db::Format format () const override
 Return the format of this DB.
 
v7::Driverdriver ()
 Access the backend DB driver.
 
std::shared_ptr< dballe::Transactiontransaction (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::Transactiontest_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...
 
- Public Member Functions inherited from dballe::db::DB
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.
 
- Public Member Functions inherited from dballe::DB
virtual std::shared_ptr< CursorStationquery_stations (const Query &query)
 Start a query on the station variables archive. More...
 
virtual std::shared_ptr< CursorStationDataquery_station_data (const Query &query)
 Query the station variables in the database. More...
 
virtual std::shared_ptr< CursorDataquery_data (const Query &query)
 Query the database. More...
 
virtual std::shared_ptr< CursorSummaryquery_summary (const Query &query)
 Query a summary of what the result would be for a query. More...
 
virtual std::shared_ptr< CursorMessagequery_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::Connectionconn
 Database connection.
 
Tracetrace = 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::Driverm_driver
 SQL driver backend.
 

Friends

class dballe::DB
 
class dballe::db::v7::Transaction
 

Additional Inherited Members

- Static Public Member Functions inherited from dballe::db::DB
static db::Format get_default_format ()
 
static void set_default_format (db::Format format)
 
static std::shared_ptr< DBconnect_from_file (const char *pathname)
 Create from a SQLite file pathname. More...
 
static std::shared_ptr< DBconnect_memory ()
 Create an in-memory database.
 
static std::shared_ptr< DBcreate (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::DBdowncast (std::unique_ptr< dballe::DB > db)
 Downcast a unique_ptr pointer.
 
static std::shared_ptr< db::DBdowncast (std::shared_ptr< dballe::DB > db)
 Downcast a shared_ptr pointer.
 
- Static Public Member Functions inherited from dballe::DB
static std::shared_ptr< DBconnect (const DBConnectOptions &opts)
 Create a new DB.
 

Detailed Description

DB-ALLe database connection for database format V7.

Member Function Documentation

◆ disappear()

void dballe::db::v7::DB::disappear ( )
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.

◆ reset()

void dballe::db::v7::DB::reset ( const char *  repinfo_file = 0)
overridevirtual

Reset the database, removing all existing DBALLE tables and re-creating them empty.

Parameters
repinfo_fileThe 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.

◆ test_transaction()

std::shared_ptr<dballe::db::Transaction> dballe::db::v7::DB::test_transaction ( bool  readonly = false)
overridevirtual

Same as transaction(), but the resulting transaction will throw an exception if commit is called.

Used for tests.

Implements dballe::db::DB.

◆ vacuum()

void dballe::db::v7::DB::vacuum ( )
overridevirtual

Remove orphan values from the database.

Orphan values are currently:

  • lev_tr values for which no data exists
  • station values for which no lev_tr exists

Depending on database size, this routine can take a few minutes to execute.

Implements dballe::db::DB.


The documentation for this class was generated from the following file: