#3167: db.connect: connection to remote database does not work
-----------------------------------+-------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Keywords: postgresql db.connect | CPU: Unspecified
Platform: Unspecified |
-----------------------------------+-------------------------
In a freshly compiled 70release:
{{{
createdb -h myRemoteServer testgrass
grass70 -c /data/GRASS/DATA7/nc_spm_08/postgres_test
db.connect driver=pg database="host=myRemoteServer,dbname=testgrass"
> db.tables -p
DBMI-PostgreSQL erreur de pilote :
Connection failed.
FATAL: la base de données « testgrass » n'existe pas
DBMI-PostgreSQL erreur de pilote :
Connection failed.
FATAL: la base de données « testgrass » n'existe pas
ERREUR :Unable to open database
<host=myRemoteServer,dbname=testgrass>
}}}
and
{{{
> g.copy vect=boundary_county,bc
Copy vector <boundary_county@PERMANENT> to current mapset as <bc>
DBMI-PostgreSQL driver error:
Connection failed.
FATAL: la base de données « testgrass » n'existe pas
DBMI-PostgreSQL driver error:
Connection failed.
FATAL: la base de données « testgrass » n'existe pas
WARNING: Unable to open database
<host=myRemoteServer,dbname=testgrass> by driver
<pg>
no database is open
no database is open
WARNING: Unable to copy table <bc>
WARNING: Unable to copy table <boundary_county> for layer 1 from
<boundary_county@PERMANENT> to <bc>
}}}
but
{{{
> psql -h myRemoteServer -l | grep testgrass
testgrass | mlennert | UTF8 | C | C |
}}}
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by mlennert):
Replying to [comment:5 mlennert]:
> The VAR file in the mapset contains this:
>
>
> {{{
> DB_DRIVER: pg
> DB_DATABASE: testgrass
> }}}
>
> i.e. no info about the host. Is this normal ?
Replying to myself: this is when I use db.connect without 'host=' in the
database string. When I use 'host=', I get:
> And if this is how it is supposed to be done, then we need to change the
man page.
>
> It just seems a bit redundant to have to indicate driver and database
twice...
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by mlennert):
The issue arises when some of the fields are empty, as for usr and pwd in
my example. Anything from that point on is ignored. When I set a username
and password with db.login, my db.tables example works like a charm.
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by mlennert):
Replying to [comment:10 mlennert]:
> The issue arises when some of the fields are empty, as for usr and pwd
in my example. Anything from that point on is ignored. When I set a
username and password with db.login, my db.tables example works like a
charm.
>
> See [http://stackoverflow.com/questions/1508754/how-do-i-parse-out-the-
fields-in-a-comma-separated-string-using-sscanf-while-sup here] for a
discussion of the issue. Would using strtok be an alternative, here ? Or
better yet: G_tokenize() ?
I've attached a proof-of-concept patch that solves the problem for me, but
it hardcodes the number of tokens. I don't know what forms login strings
can potentially take, so this definitely needs to be revised to take into
account different scenarios.
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by mlennert):
Another issue linked to the wxGUI (reported by Stefan Lüdtke - I can
confirm):
"If everything is in db.login, I can connect to the db (as reported
earlier) and list tables. However I can neither link nor import them
because they are not listed in the gui box."
I can see the database in the list, but once I select it, no tables are
listed.
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by mlennert):
One question about the new db.connect + db.login combination: if host
information is stored in .grass7/dblogin file indexed by database, how
does the system deal with two databases of the same name on two different
hosts ?
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by martinl):
Replying to [comment:11 mlennert]:
> I've attached a proof-of-concept patch that solves the problem for me,
but it hardcodes the number of tokens. I don't know what forms login
strings can potentially take, so this definitely needs to be revised to
take into account different scenarios.
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by mlennert):
Replying to [comment:14 martinl]:
> Replying to [comment:11 mlennert]:
> > I've attached a proof-of-concept patch that solves the problem for me,
but it hardcodes the number of tokens. I don't know what forms login
strings can potentially take, so this definitely needs to be revised to
take into account different scenarios.
>
> Please review attachment:dbmi_base_login2.diff
Seems to work nicely, and much more elegant than my hack, thanks !
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by martinl):
Replying to [comment:13 mlennert]:
> One question about the new db.connect + db.login combination: if host
information is stored in .grass7/dblogin file indexed by database, how
does the system deal with two databases of the same name on two different
hosts ?
Currently it's not possible, items in the file are indexed by
driver/database. Probably we could disable indexing at all. Please fill
new ticket for that.
#3167: db.connect: connection to remote database does not work
--------------------------+-----------------------------------
Reporter: mlennert | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 7.0.5
Component: Database | Version: unspecified
Resolution: | Keywords: postgresql db.connect
CPU: Unspecified | Platform: Unspecified
--------------------------+-----------------------------------
Comment (by mlennert):
Replying to [comment:15 mlennert]:
> Replying to [comment:14 martinl]:
> > Replying to [comment:11 mlennert]:
> > > I've attached a proof-of-concept patch that solves the problem for
me, but it hardcodes the number of tokens. I don't know what forms login
strings can potentially take, so this definitely needs to be revised to
take into account different scenarios.
> >
> > Please review attachment:dbmi_base_login2.diff
>
> Seems to work nicely, and much more elegant than my hack, thanks !
P.S. Someone should probably check for mysql or other db backends, or ?