X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B5C3C8BA06A for ; Thu, 10 Feb 2005 14:39:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64381-01 for ; Thu, 10 Feb 2005 14:38:31 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id D9D618B9F3A for ; Thu, 10 Feb 2005 14:38:34 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id j1AEcU69021093 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Feb 2005 07:38:32 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id j1AEcTwa070849; Thu, 10 Feb 2005 07:38:29 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id j1AEcTj6070848; Thu, 10 Feb 2005 07:38:29 -0700 (MST) (envelope-from mfuhr) Date: Thu, 10 Feb 2005 07:38:29 -0700 From: Michael Fuhr To: Murray Cumming Cc: pgsql-interfaces Subject: Re: Connecting without specifying a database Message-ID: <20050210143829.GA68483@winnie.fuhr.org> References: <1108036223.3706.12.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1108036223.3706.12.camel@localhost.localdomain> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/34 X-Sequence-Number: 5279 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/