![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
The class for initializing DatabaseTable and RawDatabaseTable instances from SQL databases. More...
#include <agrum/base/database/DBInitializerFromSQL.h>
Public Types | |
| enum class | InputType : char { STRING , DBCELL } |
| the enumeration indicating the type of the data the IDBInitializer expects as input data More... | |
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) | |
| default constructor, especially for postgresql databases | |
| DBInitializerFromSQL (const std::string &connection_string, const std::string &query, long timeout=0L) | |
| default constructor, especially for sqlite databases | |
| DBInitializerFromSQL (const DBInitializerFromSQL &from) | |
| copy constructor | |
| DBInitializerFromSQL (DBInitializerFromSQL &&from) | |
| move constructor | |
| virtual DBInitializerFromSQL * | clone () const |
| virtual copy constructor | |
| virtual | ~DBInitializerFromSQL () |
| destructor | |
Operators | |
| DBInitializerFromSQL & | operator= (const DBInitializerFromSQL &from) |
| copy operator | |
| DBInitializerFromSQL & | operator= (DBInitializerFromSQL &&from) |
| move operator | |
Accessors / Modifiers | |
| const std::vector< std::string > & | variableNames () |
| returns the names of the variables in the input dataset | |
| template<class DATABASE> | |
| void | fillDatabase (DATABASE &database, const bool retry_insertion=false) |
| fills the rows of the database table | |
| std::size_t | throwingColumn () const |
| This method indicates which column filling raised an exception, if any, during the execution of fillDatabase. | |
Protected Member Functions | |
| virtual std::vector< std::string > | variableNames_ () final |
| returns the names of the variables | |
| virtual const std::vector< std::string > & | currentStringRow_ () final |
| returns the content of the current row using strings | |
| virtual bool | nextRow_ () final |
| indicates whether there is a next row to read (and point on it) | |
| virtual const DBRow< DBCell > & | currentDBCellRow_ () |
| asks the child class for the content of the current row using dbcells | |
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 156 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 139 of file IDBInitializer.h.
| gum::learning::DBInitializerFromSQL::DBInitializerFromSQL | ( | const std::string & | dataSource, |
| const std::string & | login, | ||
| const std::string & | password, | ||
| const std::string & | query, | ||
| long | timeout = 0L ) |
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. |
Referenced by DBInitializerFromSQL(), DBInitializerFromSQL(), clone(), operator=(), and operator=().
| gum::learning::DBInitializerFromSQL::DBInitializerFromSQL | ( | const std::string & | connection_string, |
| const std::string & | query, | ||
| long | timeout = 0L ) |
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. |
| gum::learning::DBInitializerFromSQL::DBInitializerFromSQL | ( | const DBInitializerFromSQL & | from | ) |
copy constructor
the new initializer points to the same SQL query as from, but it reparses the result it from scratch.
References DBInitializerFromSQL().
| gum::learning::DBInitializerFromSQL::DBInitializerFromSQL | ( | DBInitializerFromSQL && | from | ) |
|
virtual |
destructor
|
virtual |
virtual copy constructor
Implements gum::learning::IDBInitializer.
References DBInitializerFromSQL().
|
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.
References currentStringRow_().
Referenced by currentStringRow_().
|
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::IBNLearner::Database::Database(), gum::learning::IBNLearner::Database::Database(), gum::learning::readFile(), and gum::learning::IBNLearner::readFile_().
|
finalprotectedvirtual |
indicates whether there is a next row to read (and point on it)
Implements gum::learning::IDBInitializer.
References nextRow_().
Referenced by nextRow_().
| DBInitializerFromSQL & gum::learning::DBInitializerFromSQL::operator= | ( | const DBInitializerFromSQL & | from | ) |
copy operator
the new initializer points to the same SQL query as from, but it reparses the result from scratch.
References DBInitializerFromSQL().
| DBInitializerFromSQL & gum::learning::DBInitializerFromSQL::operator= | ( | DBInitializerFromSQL && | from | ) |
move operator
the new initializer points to the same SQL query as from, but it reparses the result from scratch.
References DBInitializerFromSQL().
|
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::IBNLearner::Database::Database(), gum::learning::IBNLearner::Database::Database(), gum::learning::readFile(), and gum::learning::IBNLearner::readFile_().
|
finalprotectedvirtual |
returns the names of the variables
Implements gum::learning::IDBInitializer.