summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules/sql.h9
-rw-r--r--src/modules/extra/m_mysql.cpp6
-rw-r--r--src/modules/extra/m_pgsql.cpp6
-rw-r--r--src/modules/extra/m_sqlite3.cpp4
4 files changed, 20 insertions, 5 deletions
diff --git a/include/modules/sql.h b/include/modules/sql.h
index 15e8260b6..78cfe89cd 100644
--- a/include/modules/sql.h
+++ b/include/modules/sql.h
@@ -228,12 +228,19 @@ class SQL::Query : public classbase
*/
class SQL::Provider : public DataProvider
{
+ private:
+ /** The name of the database tag in the config. */
+ const std::string dbid;
+
public:
Provider(Module* Creator, const std::string& Name)
- : DataProvider(Creator, Name)
+ : DataProvider(Creator, "SQL/" + Name)
{
}
+ /** Retrieves the name of the database tag in the config. */
+ const std::string& GetId() const { return dbid; }
+
/** Submit an asynchronous SQL query.
* @param callback The result reporting point
* @param query The hardcoded query string. If you have parameters to substitute, see below.
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index dcdbe0004..a79ef01ad 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -284,8 +284,10 @@ class SQLConnection : public SQL::Provider
Mutex lock;
// This constructor creates an SQLConnection object with the given credentials, but does not connect yet.
- SQLConnection(Module* p, ConfigTag* tag) : SQL::Provider(p, "SQL/" + tag->getString("id")),
- config(tag), connection(NULL)
+ SQLConnection(Module* p, ConfigTag* tag)
+ : SQL::Provider(p, tag->getString("id"))
+ , config(tag)
+ , connection(NULL)
{
}
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index 37cf92704..b0f0b4597 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -176,7 +176,11 @@ class SQLConn : public SQL::Provider, public EventHandler
QueueItem qinprog; /* If there is currently a query in progress */
SQLConn(Module* Creator, ConfigTag* tag)
- : SQL::Provider(Creator, "SQL/" + tag->getString("id")), conf(tag), sql(NULL), status(CWRITE), qinprog(NULL, "")
+ : SQL::Provider(Creator, tag->getString("id"))
+ , conf(tag)
+ , sql(NULL)
+ , status(CWRITE)
+ , qinprog(NULL, "")
{
if (!DoConnect())
{
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp
index 8efdf876f..405d4b783 100644
--- a/src/modules/extra/m_sqlite3.cpp
+++ b/src/modules/extra/m_sqlite3.cpp
@@ -112,7 +112,9 @@ class SQLConn : public SQL::Provider
reference<ConfigTag> config;
public:
- SQLConn(Module* Parent, ConfigTag* tag) : SQL::Provider(Parent, "SQL/" + tag->getString("id")), config(tag)
+ SQLConn(Module* Parent, ConfigTag* tag)
+ : SQL::Provider(Parent, tag->getString("id"))
+ , config(tag)
{
std::string host = tag->getString("hostname");
if (sqlite3_open_v2(host.c_str(), &conn, SQLITE_OPEN_READWRITE, 0) != SQLITE_OK)