Project

General

Profile

Feature #4897

Allow FHiCL configuration of DB port in DBInterface.

Added by Christopher Green almost 6 years ago. Updated over 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
Start date:
11/04/2013
Due date:
% Done:

0%

Estimated time:
Duration:

Description

The DBInterface service does not currently allow the configuration of the port number of the DB, meaning that it is difficult to configure SSH tunnel access on multi-user machines on local networks. Please allow a port configuration parameter to the service configuration to allow easier tunneling.

History

#1 Updated by Christopher Green almost 6 years ago

The following patch allows :port on the end of the host name:

diff --git a/ds50daq/online/ArtServices/ds50db_interface.cc b/ds50daq/online/ArtServices/ds50db_interface.cc
index 460628e..397d606 100644
--- a/ds50daq/online/ArtServices/ds50db_interface.cc
+++ b/ds50daq/online/ArtServices/ds50db_interface.cc
@@ -1,8 +1,17 @@
 #include "cetlib/exception.h" 
+#include "cetlib/split.h" 
 #include "ds50daq/online/ArtServices/ds50db_interface.hh" 

+#include <string>
+#include <vector>
+
 ds50::db::interface::interface (const std::string& host, const std::string& db, const std::string& user, const std::string& pwd): current_run_(-1) {
-  std::string connection_info = "host = " + host + " user = " + user + " password = " + pwd + " dbname = " + db;
+  std::vector<std::string> splitHost;
+  cet::split(host, ':', std::back_inserter(splitHost));
+  std::string connection_info = "host = " + splitHost[0] + " user = " + user + " password = " + pwd + " dbname = " + db;
+  if (splitHost.size() == 2) {
+    connection_info += " port = " + splitHost[1];
+  }
   try {
     c_ = std::unique_ptr<connection>(new connection (connection_info));
   } catch (const std::runtime_error& e) {

With this, the connection now works, but there seems to be a problem accessing the means table. I will have to take this up with Alden.

Thanks,
Chris.

#2 Updated by Kurt Biery over 5 years ago

  • Target version set to NeededEnhancements


Also available in: Atom PDF