pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedConnecting without specifying a database
3+ messages / 3 participants
[nested] [flat]
* Connecting without specifying a database
@ 2005-02-10 11:50 Murray Cumming <murrayc@murrayc.com>
0 siblings, 2 replies; 3+ messages in thread
From: Murray Cumming @ 2005-02-10 11:50 UTC (permalink / raw)
To: pgsql-interfaces
Can PQconnectdb(), or something else, be used without specifying the
dbname in the connection string? I want to connect just so that I can
create a database that does not exist yet.
When I don't specify the dbname, PQconnectdb() tries to connect to a
database with the same name as the user, and then complains that it does
not exist. Is it really necessary for each user to have an empty
database like this?
--
Murray Cumming
murrayc@murrayc.com
www.murrayc.com
www.openismus.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Connecting without specifying a database
@ 2005-02-10 13:12 Robert Treat <xzilla@users.sourceforge.net>
parent: Murray Cumming <murrayc@murrayc.com>
1 sibling, 0 replies; 3+ messages in thread
From: Robert Treat @ 2005-02-10 13:12 UTC (permalink / raw)
To: Murray Cumming <murrayc@murrayc.com>; +Cc: pgsql-interfaces
On Thursday 10 February 2005 06:50, Murray Cumming wrote:
> Can PQconnectdb(), or something else, be used without specifying the
> dbname in the connection string? I want to connect just so that I can
> create a database that does not exist yet.
>
> When I don't specify the dbname, PQconnectdb() tries to connect to a
> database with the same name as the user, and then complains that it does
> not exist. Is it really necessary for each user to have an empty
> database like this?
Most applications choose to connect to template1 in these scenarios.
--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Connecting without specifying a database
@ 2005-02-10 14:38 Michael Fuhr <mike@fuhr.org>
parent: Murray Cumming <murrayc@murrayc.com>
1 sibling, 0 replies; 3+ messages in thread
From: Michael Fuhr @ 2005-02-10 14:38 UTC (permalink / raw)
To: Murray Cumming <murrayc@murrayc.com>; +Cc: pgsql-interfaces
On Thu, Feb 10, 2005 at 12:50:23PM +0100, Murray Cumming wrote:
>
> Can PQconnectdb(), or something else, be used without specifying the
> dbname in the connection string? I want to connect just so that I can
> create a database that does not exist yet.
See "Environment Variables" in the libpq chapter of the documentation:
http://www.postgresql.org/docs/8.0/static/libpq-envars.html
> When I don't specify the dbname, PQconnectdb() tries to connect to a
> database with the same name as the user, and then complains that it does
> not exist. Is it really necessary for each user to have an empty
> database like this?
No, but you have to connect to *some* database. As Robert Treat
mentioned, you could connect to template1 if you just need to issue
a CREATE DATABASE statement.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-02-10 14:38 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-10 11:50 Connecting without specifying a database Murray Cumming <murrayc@murrayc.com>
2005-02-10 13:12 ` Robert Treat <xzilla@users.sourceforge.net>
2005-02-10 14:38 ` Michael Fuhr <mike@fuhr.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox