db_bridge/postgresql_db.cpp
changeset 20 5fec678f931b
parent 18 f3657061ec00
child 40 be3f5582b839
equal deleted inserted replaced
19:933d86c1ff71 20:5fec678f931b
     3  * Copyright 2008 (C) Markus Broeker
     3  * Copyright 2008 (C) Markus Broeker
     4  */
     4  */
     5 
     5 
     6 #include <postgresql_db.h>
     6 #include <postgresql_db.h>
     7 #include <exception>
     7 #include <exception>
       
     8 #include <console.h>
     8 
     9 
     9 PostgreSQL_DB::PostgreSQL_DB (std::string srv, std::string usr, std::string pwd, std::string db)
    10 PostgreSQL_DB::PostgreSQL_DB (std::string srv, std::string usr, std::string pwd, std::string db)
    10 {
    11 {
    11     server = srv;
    12     server = srv;
    12     user = (usr != "") ? usr : getenv ("USER");
    13     user = (usr != "") ? usr : getenv ("USER");
    15 
    16 
    16     conninfo = "user=" + user + " dbname=" + database;
    17     conninfo = "user=" + user + " dbname=" + database;
    17 
    18 
    18     if (server != "" && pwd == "") {
    19     if (server != "" && pwd == "") {
    19         std::cout << "Passwort von " << user << "@" << server << ": ";
    20         std::cout << "Passwort von " << user << "@" << server << ": ";
    20         std::getline (std::cin, password);
    21         Console::getpass (password);
    21         conninfo += " host=" + server + " password=" + password;
    22         conninfo += " host=" + server + " password=" + password;
    22     }
    23     }
    23 }
    24 }
    24 
    25 
    25 PostgreSQL_DB::~PostgreSQL_DB ()
    26 PostgreSQL_DB::~PostgreSQL_DB ()