![]() |
aGrUM
0.16.0
|
The class for initializing DatabaseTable and RawDatabaseTable instances from SQL databases. More...
#include <agrum/learning/database/DBInitializerFromSQL.h>
Public Member Functions | |
Constructors / Destructors | |
DBInitializerFromSQL (const std::string &dataSource, const std::string &login, const std::string &password, const std::string &query, long timeout=0L, const allocator_type &alloc=allocator_type()) | |
default constructor, especially for postgresql databases More... | |
DBInitializerFromSQL (const std::string &connection_string, const std::string &query, long timeout=0L, const allocator_type &alloc=allocator_type()) | |
default constructor, especially for sqlite databases More... | |
DBInitializerFromSQL (const DBInitializerFromSQL< ALLOC > &from) | |
copy constructor More... | |
DBInitializerFromSQL (const DBInitializerFromSQL< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
DBInitializerFromSQL (DBInitializerFromSQL< ALLOC > &&from) | |
move constructor More... | |
DBInitializerFromSQL (DBInitializerFromSQL< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
virtual DBInitializerFromSQL< ALLOC > * | clone () const |
virtual copy constructor More... | |
virtual DBInitializerFromSQL< ALLOC > * | clone (const allocator_type &alloc) const |
virtual copy constructor with a given allocator More... | |
virtual | ~DBInitializerFromSQL () |
destructor More... | |
Operators | |
DBInitializerFromSQL< ALLOC > & | operator= (const DBInitializerFromSQL< ALLOC > &from) |
copy operator More... | |
DBInitializerFromSQL< ALLOC > & | operator= (DBInitializerFromSQL< ALLOC > &&from) |
move operator More... | |
Accessors / Modifiers | |
const std::vector< std::string, ALLOC< std::string > > & | variableNames () |
returns the names of the variables in the input dataset More... | |
template<template< template< typename > class > class DATABASE> | |
void | fillDatabase (DATABASE< ALLOC > &database, const bool retry_insertion=false) |
fills the rows of the database table More... | |
std::size_t | throwingColumn () const |
This method indicates which column filling raised an exception, if any, during the execution of fillDatabase. More... | |
allocator_type | getAllocator () const |
returns the allocator used More... | |
Public Types | |
using | allocator_type = ALLOC< std::string > |
type for the allocators passed in arguments of methods More... | |
enum | InputType : char { InputType::STRING, InputType::DBCELL } |
the enumeration indicating the type of the data the IDBInitializer expects as input data More... | |
Protected Member Functions | |
virtual std::vector< std::string, ALLOC< std::string > > | _variableNames () final |
returns the names of the variables More... | |
virtual const std::vector< std::string, ALLOC< std::string > > & | _currentStringRow () final |
returns the content of the current row using strings More... | |
virtual bool | _nextRow () final |
indicates whether there is a next row to read (and point on it) More... | |
virtual const DBRow< DBCell, ALLOC > & | _currentDBCellRow () |
asks the child class for the content of the current row using dbcells More... | |
The class for initializing DatabaseTable and RawDatabaseTable instances from SQL databases.
In aGrUM, the usual way to create DatabaseTable instances used by learning algorithms is to use the 4-step process below:
Definition at line 137 of file DBInitializerFromSQL.h.
using gum::learning::DBInitializerFromSQL< ALLOC >::allocator_type = ALLOC< std::string > |
type for the allocators passed in arguments of methods
Definition at line 140 of file DBInitializerFromSQL.h.
|
stronginherited |
the enumeration indicating the type of the data the IDBInitializer expects as input data
Enumerator | |
---|---|
STRING | |
DBCELL |
Definition at line 121 of file IDBInitializer.h.
gum::learning::DBInitializerFromSQL< ALLOC >::DBInitializerFromSQL | ( | const std::string & | dataSource, |
const std::string & | login, | ||
const std::string & | password, | ||
const std::string & | query, | ||
long | timeout = 0L , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
default constructor, especially for postgresql databases
This will read the result of query and load it in memory.
dataSource | A declared dataSource in your odbc configuration file (usually /etc/odbc.ini). |
login | The dataSource login. |
password | The dataSource password. |
query | The SQL query used as a database. |
timeout | Defines a timeout for accessing the SQL database, if 0 then no timeout is set. |
alloc | the allocator used to allocate all the data structures |
gum::learning::DBInitializerFromSQL< ALLOC >::DBInitializerFromSQL | ( | const std::string & | connection_string, |
const std::string & | query, | ||
long | timeout = 0L , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
default constructor, especially for sqlite databases
This will read the result of query and load it in memory.
connection_string | a string specifying to nanODBC how to connect to a SQL database |
query | The SQL query used as a database. |
timeout | Defines a timeout for accessing the SQL database, if 0 then no timeout is set. |
alloc | the allocator used to allocate all the data structures |
gum::learning::DBInitializerFromSQL< ALLOC >::DBInitializerFromSQL | ( | const DBInitializerFromSQL< ALLOC > & | from | ) |
copy constructor
the new initializer points to the same SQL query as from, but it reparses the result it from scratch.
gum::learning::DBInitializerFromSQL< ALLOC >::DBInitializerFromSQL | ( | const DBInitializerFromSQL< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
the new initializer points to the same SQL query as from, but it reparses the result from scratch.
gum::learning::DBInitializerFromSQL< ALLOC >::DBInitializerFromSQL | ( | DBInitializerFromSQL< ALLOC > && | from | ) |
move constructor
gum::learning::DBInitializerFromSQL< ALLOC >::DBInitializerFromSQL | ( | DBInitializerFromSQL< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
destructor
|
protectedvirtualinherited |
asks the child class for the content of the current row using dbcells
If the child class parses DBRows, this method should be overloaded
|
finalprotectedvirtual |
returns the content of the current row using strings
Reimplemented from gum::learning::IDBInitializer< ALLOC >.
|
finalprotectedvirtual |
indicates whether there is a next row to read (and point on it)
Implements gum::learning::IDBInitializer< ALLOC >.
|
finalprotectedvirtual |
returns the names of the variables
Implements gum::learning::IDBInitializer< ALLOC >.
|
virtual |
virtual copy constructor
Implements gum::learning::IDBInitializer< ALLOC >.
|
virtual |
virtual copy constructor with a given allocator
Implements gum::learning::IDBInitializer< ALLOC >.
|
inherited |
fills the rows of the database table
This method may raise exceptions when trying to insert new rows into the database table. See Method insertRow() of the database table.
Referenced by gum::learning::genericBNLearner::__readFile(), gum::learning::genericBNLearner::Database::Database(), and gum::learning::readFile().
|
inherited |
returns the allocator used
DBInitializerFromSQL< ALLOC >& gum::learning::DBInitializerFromSQL< ALLOC >::operator= | ( | const DBInitializerFromSQL< ALLOC > & | from | ) |
copy operator
the new initializer points to the same SQL query as from, but it reparses the result from scratch.
DBInitializerFromSQL< ALLOC >& gum::learning::DBInitializerFromSQL< ALLOC >::operator= | ( | DBInitializerFromSQL< ALLOC > && | from | ) |
move operator
the new initializer points to the same SQL query as from, but it reparses the result from scratch.
|
inherited |
This method indicates which column filling raised an exception, if any, during the execution of fillDatabase.
|
inherited |
returns the names of the variables in the input dataset
Referenced by gum::learning::genericBNLearner::__readFile(), gum::learning::genericBNLearner::Database::Database(), and gum::learning::readFile().