SOCI C++ FATAL: database "testDB" does not exist

0

To znów ja :} Tym razem mam problem z połączeniem się z bazą, zorbiłem to:

W PostgreSQL:

  1. CREATE USER robert WITH ENCRYPTED PASSWORD 'haslo';
  2. CREATE DATABASE testDB;
  3. GRANT ALL PRIVILEGES ON DATABASE testDB TO robert;

I mam kod w C++ :

#include <iostream>
#include <soci.h>
#include <string>
using std::string;
using std::cout;
#include <postgresql/soci-postgresql.h>

bool connectToDatabase(string databaseName, string user, string password)
{
	try
   { 
      soci::session sql(soci::postgresql, "dbname=" +databaseName + " user="+user + " password="+password);
   }
   catch (soci::postgresql_soci_error const & e)
   {
      std::cerr << "PostgreSQL error: " << e.sqlstate() << " " << e.what() << std::endl;
	return false;	
   }
   catch (std::exception const & e)
   {
      std::cerr << "Some other error: " << e.what() << std::endl;
	return false;   
	}
	return true;
}
 
int main(int argc, char **argv)
{
   cout << connectToDatabase("testDB", "robert", "haslo"); 

   return 0;

}

a przy kompilacji dostaję błąd:

Some other error: Cannot establish connection to the database.
FATAL: database "testDB" does not exist

??

0

dobra juz wiem:

trzeba zamienic:

cout << connectToDatabase("testDB", "robert", "haslo"); 

na cout << connectToDatabase("testdb", "robert", "haslo");

1 użytkowników online, w tym zalogowanych: 0, gości: 1