13 #include <unordered_map>
90 namespace column_type {
98 namespace insert_mode {
186 template <
typename T>
247 template <
typename T>
255 return static_cast<T*
>(
fBlob);
266 mutable std::unordered_map<std::string, int>
fColMap;
267 static std::map<TString, KVSQLite::column_type::types>
type_map;
364 std::cout <<
"Error in <KVSQLite::table::get_column(const TString&)> : "
365 <<
n <<
" is not a column of table " <<
name() << std::endl;
373 std::cout <<
name() <<
"\n";
374 for (std::vector<KVSQLite::column>::const_iterator it =
fColumns.begin(); it !=
fColumns.end(); ++it) it->print();
391 mutable std::unordered_map<std::string, KVSQLite::table>
fTables;
405 const TString& condition =
"")
const;
482 std::cout <<
"Error in <KVSQLite::database::get_table(const TString&)> : "
483 << name <<
" is not a table of database" << std::endl;
484 return fTables.begin()->second;
494 bool distinct =
false,
const TString& anything_else =
"")
const;
497 const TString& selection =
"",
const TString& anything_else =
"");
499 const TString& selection =
"",
const TString& anything_else =
"");
501 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)
void set_data_from_statement(TSQLStatement *s, int idx=-1) const
void set_table(const TString &name)
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)
column(int idx, const TString &name, KVSQLite_column_type type)
void set_constraint(const TString &c)
const char * get_table() const
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="")
std::list< const column * > fSQLstmtCols
int count(const TString &table, const TString &column="*", const TString &selection="", bool distinct=false) const
database(const TString &dbfile)
TGraph * create_graph(const TString &tablename, const TString &Xcolumn, const TString &Ycolumn, const TString &selection="")
std::unique_ptr< TSQLResult > SelectRowsFromTable(const TString &table, const TString &columns="*", const TString &condition="") const
std::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)
void print_selection(const TString &table, const TString &columns, const TString &condition, int column_width=20) const
Print on stdout contents of database.
std::unique_ptr< TSQLiteServer > fDBserv
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()
bool select_data(const TString &tables, const TString &columns="*", const TString &selection="", bool distinct=false, const TString &anything_else="") const
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 add_table(const table &)
void PrintResults(TSQLResult *tabent, int column_width=20) const
KVSQLite::table & get_table(const TString &name)
bool prepare_data_insertion(const TString &)
void clear_table(const TString &name)
Delete all data from table.
void print_selected_data(const TString &tables, const TString &columns="*", const TString &selection="", bool distinct=false, const TString &anything_else="")
Print out results of a call to select_data().
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)
TString get_column_names(const TString &exclude="", const TString &delim=",") const
table(const TString &Name="")
column & add_column(const KVSQLite::column &c)
void set_name(const TString &name)
KVSQLite::column & get_column(const TString &n)
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
const column & add_foreign_key(const TString &other_table, const TString &other_column)
KVSQLite::column & get_column(int i)
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 KVSQLite::column & operator[](int i) const
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