--- a/db_bridge/mysql_db.cpp
+++ b/db_bridge/mysql_db.cpp
@@ -8,10 +8,15 @@
MySQL_DB::MySQL_DB (std::string srv, std::string usr, std::string pwd, std::string db)
{
server = srv;
- user = usr;
+ user = (usr != "") ? usr : getenv ("USER");
password = pwd;
database = db;
conn = mysql_init (NULL);
+
+ if (server != "" && pwd == "") {
+ std::cout << "Passwort von " << user << "@" << server << ": ";
+ std::getline (std::cin, password);
+ }
}
MySQL_DB::~MySQL_DB ()
@@ -24,6 +29,9 @@
bool MySQL_DB::connect ()
{
+ std::cerr << "Verbindungsparameter:" << " host=" << ((server != "") ? server : "LOCAL")
+ << " user=" << user << " password=" << password << " database=" << database << std::endl;
+
if (!mysql_real_connect (conn, server.c_str (), user.c_str (), password.c_str (), database.c_str (), 0, NULL, 0)) {
std::cerr << server << ": " << mysql_error (conn) << std::endl;
return false;