SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
UpdateDBConnection.cpp
1 // (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration.
2 //
3 // This software is distributed under the terms of the GNU General Public
4 // Licence version 3 (GPL Version 3), copied verbatim in the file "LICENCE".
5 //
6 // In applying this licence, CERN does not waive the privileges and immunities
7 // granted to it by virtue of its status as an Intergovernmental Organization
8 // or submit itself to any jurisdiction.
9 
10 
11 // STL
12 #include <memory>
13 #include <random>
14 
15 // SQLite3
16 #include "sqlite3.h"
17 
18 // SQLamarr
19 #include "SQLamarr/UpdateDBConnection.h"
20 #include "SQLamarr/GlobalPRNG.h"
21 #include "SQLamarr/db_functions.h"
22 
23 namespace SQLamarr
24 {
25  //============================================================================
26  // Constructor
27  //============================================================================
29  SQLite3DB& db,
30  std::string filename,
31  int flags
32  )
33  : m_database(db)
34  , m_filename(filename)
35  , m_flags(flags)
36  {}
37 
38  //============================================================================
39  // execute
40  //============================================================================
42  {
43  update_db_connection(m_database, m_filename, m_flags);
44  }
45 }
46 
47 
void execute() override
Execute the algorithm, cleaning the database.
UpdateDBConnection(SQLite3DB &db, std::string filename, int flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_URI)
Constructor.
A database connection handler easying sharing the DB between C++ and Python.
Definition: db_functions.py:24
void update_db_connection(SQLite3DB &old_db, const std::string &db_uri, int flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_URI)
Force synchronization to disk by closing and opening the connection.