Permalink
Browse files

host = '' , host = None and ommiting host all default to unix-domain …

…socket in /tmp
  • Loading branch information...
1 parent e016bd6 commit 1b84f2d454c5f7e34c38427aeae432c1ee9b3e97 @artemp artemp committed Feb 6, 2007
@@ -41,19 +41,21 @@ class Connection
private:
PGconn *conn_;
public:
- Connection(std::string const& uri,
+ Connection(std::string const& host,
std::string const& port,
std::string const& dbname,
std::string const& username,
std::string const& password)
{
- std::string connStr="host="+uri;
- if (port.length()) connStr+=" port="+port;
+
+ std::string connStr;
+ if (host.length()) connStr += "host="+host;
+ if (port.length()) connStr += " port="+port;
connStr+=" dbname="+dbname;
connStr+=" user="+username;
connStr+=" password="+password;
connStr+=" connect_timeout=4"; // todo: set by client (param)
-
+
conn_=PQconnectdb(connStr.c_str());
if (PQstatus(conn_) == CONNECTION_BAD)
{
@@ -40,31 +40,31 @@ class ConnectionCreator
{
public:
- ConnectionCreator(string const& url,
+ ConnectionCreator(string const& host,
string const& port,
string const& dbname,
string const& user,
string const& pass)
- : url_(url),
+ : host_(host),
port_(port),
dbname_(dbname),
user_(user),
pass_(pass) {}
T* operator()() const
{
- return new T(url_,port_,dbname_,user_,pass_);
+ return new T(host_,port_,dbname_,user_,pass_);
}
std::string id() const
{
- return url_ + ":"
+ return host_ + ":"
+ dbname_ + ":"
+ port_ +":"
+ user_ ;
}
private:
- string url_;
+ string host_;
string port_;
string dbname_;
string user_;
@@ -33,7 +33,7 @@
DATASOURCE_PLUGIN(postgis_datasource)
- const std::string postgis_datasource::GEOMETRY_COLUMNS="geometry_columns";
+const std::string postgis_datasource::GEOMETRY_COLUMNS="geometry_columns";
const std::string postgis_datasource::SPATIAL_REF_SYS="spatial_ref_system";
using std::clog;

0 comments on commit 1b84f2d

Please sign in to comment.