OpenMS
Loading...
Searching...
No Matches
SqliteConnector.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Hannes Roest $
6// $Authors: Hannes Roest $
7// --------------------------------------------------------------------------
8
9#pragma once
10
13
14#include <string>
15#include <vector>
16
17namespace OpenMS
18{
19 namespace Internal
20 {
23 struct SqliteConnectorFriend;
24 }
25
40 class OPENMS_DLLAPI SqliteConnector
41 {
42 public:
43
45 enum class SqlOpenMode
46 {
47 READ_ONLY,
48#ifndef READONLY
49 READONLY = READ_ONLY,
50#endif
51 READWRITE,
52 READWRITE_OR_CREATE
53 };
54
56 SqliteConnector() = delete;
57
60 explicit SqliteConnector(const std::string& filename, const SqlOpenMode mode = SqlOpenMode::READWRITE_OR_CREATE);
61
64
72 bool tableExists(const std::string& tablename);
73
76 Size countTableRows(const std::string& table_name);
77
86 bool columnExists(const std::string& tablename, const std::string& colname);
87
97 void executeStatement(const std::string& statement);
98
115 void executeBindStatement(const std::string& prepare_statement, const std::vector<std::string>& data);
116
117 protected:
118
127 void openDatabase_(const std::string& filename, const SqlOpenMode mode);
128
132 void* db_ = nullptr;
133
135 };
136
137} // namespace OpenMS
File adapter for Sqlite files.
Definition SqliteConnector.h:41
bool columnExists(const std::string &tablename, const std::string &colname)
Checks whether the given table contains a certain column.
~SqliteConnector()
Destructor.
void executeBindStatement(const std::string &prepare_statement, const std::vector< std::string > &data)
Executes raw data SQL statements (insert statements)
SqliteConnector(const std::string &filename, const SqlOpenMode mode=SqlOpenMode::READWRITE_OR_CREATE)
SqlOpenMode
how an sqlite db should be opened
Definition SqliteConnector.h:46
SqliteConnector()=delete
Default constructor.
bool tableExists(const std::string &tablename)
Checks whether the given table exists.
void openDatabase_(const std::string &filename, const SqlOpenMode mode)
Opens a new SQLite database.
void executeStatement(const std::string &statement)
Executes a given SQL statement (insert statement)
Size countTableRows(const std::string &table_name)
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition SqliteConnector_impl.h:42