14 #include <unordered_map>
91 namespace column_type {
99 namespace insert_mode {
177 template <
typename T>
238 template <
typename T>
246 return static_cast<T*
>(
fBlob);
258 mutable std::unordered_map<std::string, int>
fColMap;
260 mutable std::map<std::string, int>
fColMap;
262 static std::map<TString, KVSQLite::column_type::types>
type_map;
342 std::cout <<
"Error in <KVSQLite::table::operator[const TString&]> : "
343 <<
n <<
" is not a column of table " <<
name() << std::endl;
351 std::cout <<
"Error in <KVSQLite::table::operator[const TString&]> : "
352 <<
n <<
" is not a column of table " <<
name() << std::endl;
360 std::cout <<
name() <<
"\n";
361 for (std::vector<KVSQLite::column>::const_iterator it =
fColumns.begin(); it !=
fColumns.end(); ++it) it->print();
377 mutable std::unordered_map<std::string, KVSQLite::table>
fTables;
379 mutable std::map<std::string, KVSQLite::table>
fTables;
393 const TString& condition =
"")
const;
459 std::cout <<
"Error in <KVSQLite::database::operator[const TString&]> : "
460 << name <<
" is not a table of database" << std::endl;
461 return fTables.begin()->second;
468 std::cout <<
"Error in <KVSQLite::database::operator[const TString&]> : "
469 << name <<
" is not a table of database" << std::endl;
470 return fTables.begin()->second;
480 bool distinct =
false,
const TString& anything_else =
"")
const;
483 const TString& selection =
"",
const TString& anything_else =
"");
485 const TString& selection =
"",
const TString& anything_else =
"");
487 const TString& selection =
"",
const TString& anything_else =
"");
#define ClassDef(name, id)
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
A generic named parameter storing values of different types.
void Set(const char *, const char *)
Strings used to represent a set of ranges of values.
Long_t fBlobSize
binary data
void set_binary_data(T &x)
const char * type_name() const
std::pair< TString, KVSQLite_column_type > fNameType
const column & operator=(const T &x)
static std::map< KVSQLite::column_type::types, TString > inv_type_map
void set_data_in_statement(TSQLStatement *, int idx=-1) const
const char * name() const
void set_foreign_key(const TString &_table, const TString &_column)
const char * get_declaration() const
return declaration for column, including type & constraint
KVSQLite_column_type type() const
void set_binary_data(T *x)
const KVNamedParameter & data() const
void set_data(const T &x)
void set_data_from_statement(TSQLStatement *s, int idx=-1)
column(int idx, const TString &name, KVSQLite_column_type type)
void set_constraint(const TString &c)
Interface to ROOT SQLite database backend ,.
int get_number_of_tables() const
void copy_table_data(const TString &source, const TString &destination, const TString &columns="*", const TString &selection="")
void add_table(KVSQLite::table &)
int count(const TString &table, const TString &column="*", const TString &selection="", bool distinct=false) const
database(const TString &dbfile)
KVSQLite::table * fBulkTable
unique_ptr< TSQLiteServer > fDBserv
TGraph * create_graph(const TString &tablename, const TString &Xcolumn, const TString &Ycolumn, const TString &selection="")
unique_ptr< TSQLStatement > fSQLstmt
bool update(const TString &table, const TString &columns, const TString &selection="")
void delete_data(const TString &table, const TString &selection="")
void show_tables() const
print list of tables
const KVSQLite::table & operator[](const TString &name) const
column & add_column(const TString &table, const TString &name, const TString &type)
bool select_data(const TString &table, const TString &columns="*", const TString &selection="", bool distinct=false, const TString &anything_else="") const
void print_selection(const TString &table, const TString &columns, const TString &condition, int column_width=20) const
Print on stdout contents of database.
unique_ptr< TSQLResult > SelectRowsFromTable(const TString &table, const TString &columns="*", const TString &condition="") const
database & operator=(const database &db)
KVSQLite::table & operator[](const TString &name)
bool is_inserting() const
void open(const TString &dbfile)
bool has_table(const TString &table)
void end_data_insertion()
KVNameValueList get_name_value_list(const TString &table, const TString &name_column, const TString &value_column, const TString &selection="", const TString &anything_else="")
bool get_next_result() const
TString get_string_list(const TString &table, const TString &column, const TString &selection="", const TString &anything_else="")
void Dump() const
Print on stdout contents of database.
std::unordered_map< std::string, KVSQLite::table > fTables
database(const database &db)
void PrintResults(TSQLResult *tabent, int column_width=20) const
bool prepare_data_insertion(const TString &)
void clear_table(const TString &name)
Delete all data from table.
void read_table_infos()
initialise map of database tables from existing database
void add_missing_columns(const TString &table, const KVNameValueList &l)
KVNumberList get_integer_list(const TString &table, const TString &column, const TString &selection="", const TString &anything_else="")
static std::map< TString, KVSQLite::column_type::types > type_map
const char * name() const
bool is_temporary() const
KVSQLite::column & operator[](int i)
const column & add_primary_key(const TString &name)
void set_all_columns_null()
set the value of all columns in the table to NULL
std::vector< KVSQLite::column > fColumns
void set_temporary(bool temp=true)
void show_columns() const
print list of columns
table(const TString &Name, const std::vector< KVSQLite::column > &cols)
table(const TString &Name="")
column & add_column(const KVSQLite::column &c)
void set_name(const TString &name)
KVSQLite::column & operator[](const TString &n)
int check_columns(const KVNameValueList &)
void set_insert_mode(KVSQLite_insert_mode i)
int number_of_columns() const
const KVSQLite::column & operator[](const TString &n) const
bool has_column(const TString &name) const
column & add_column(const TString &name, KVSQLite_column_type type)
void prepare_data(const KVNameValueList &, const KVNamedParameter *=nullptr)
const char * get_insert_command() const
KVSQLite_insert_mode fInsert
const column & add_foreign_key(const TString &name, const TString &other_table, const TString &other_column)
std::unordered_map< std::string, int > fColMap
const char * Data() const
RooCmdArg Name(const char *name)
KVSQLite::column_type::types KVSQLite_column_type
KVSQLite::insert_mode::types KVSQLite_insert_mode