libdballe 9.6
db/v7/db.h
1#ifndef DBA_DB_V7_H
2#define DBA_DB_V7_H
3
4#include <dballe/fwd.h>
5#include <dballe/sql/fwd.h>
6#include <dballe/db/db.h>
7#include <dballe/db/v7/trace.h>
8#include <dballe/db/v7/fwd.h>
9#include <wreport/varinfo.h>
10#include <string>
11#include <memory>
12
13namespace dballe {
14namespace db {
15namespace v7 {
16
20class DB : public dballe::db::DB
21{
22public:
24 std::shared_ptr<dballe::sql::Connection> conn;
26 Trace* trace = nullptr;
28 bool explain_queries = false;
29
30protected:
33
34 void init_after_connect();
35
36public:
37 DB(std::shared_ptr<dballe::sql::Connection> conn);
38 virtual ~DB();
39
40 db::Format format() const { return Format::V7; }
41
44
45 std::shared_ptr<dballe::Transaction> transaction(bool readonly=false) override;
46 std::shared_ptr<dballe::db::Transaction> test_transaction(bool readonly=false) override;
47
48 void disappear();
49
61 void reset(const char* repinfo_file = 0);
62
67
77 void vacuum();
78
79 friend class dballe::DB;
80 friend class dballe::db::v7::Transaction;
81};
82
83}
84}
85}
86#endif
Definition: db.h:297
Definition: db/db.h:253
DB-ALLe database connection for database format V7.
Definition: db/v7/db.h:21
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.
db::Format format() const
Return the format of this DB.
Definition: db/v7/db.h:40
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.
void reset(const char *repinfo_file=0)
Reset the database, removing all existing DBALLE tables and re-creating them empty.
Trace * trace
Database query tracing.
Definition: db/v7/db.h:26
bool explain_queries
True if we print an EXPLAIN trace of all queries to stderr.
Definition: db/v7/db.h:28
v7::Driver * m_driver
SQL driver backend.
Definition: db/v7/db.h:32
void disappear()
Remove all our traces from the database, if applicable.
void delete_tables()
Delete all the DB-ALLe tables from the database.
std::shared_ptr< dballe::sql::Connection > conn
Database connection.
Definition: db/v7/db.h:24
void vacuum()
Remove orphan values from the database.
Functions used to connect to DB-All.e and insert, query and delete data.
Forward declarations for public dballe/sql names.
Definition: driver.h:20
Definition: db/v7/trace.h:195
Definition: transaction.h:16