From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Kost Newsgroups: gmane.emacs.help Subject: Re: help with using sql-connect Date: Wed, 17 Dec 2014 22:49:27 +0300 Message-ID: <878ui6gipk.fsf@gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1418845807 27032 80.91.229.3 (17 Dec 2014 19:50:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Dec 2014 19:50:07 +0000 (UTC) Cc: help-gnu-emacs To: Luca Ferrari Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 17 20:50:00 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y1Kbf-0006ut-S6 for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Dec 2014 20:50:00 +0100 Original-Received: from localhost ([::1]:51312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1Kbf-0003mF-8e for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Dec 2014 14:49:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1KbL-0003lE-Ua for help-gnu-emacs@gnu.org; Wed, 17 Dec 2014 14:49:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1KbC-0003d1-TF for help-gnu-emacs@gnu.org; Wed, 17 Dec 2014 14:49:39 -0500 Original-Received: from mail-lb0-x22e.google.com ([2a00:1450:4010:c04::22e]:65330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1KbC-0003cC-LL for help-gnu-emacs@gnu.org; Wed, 17 Dec 2014 14:49:30 -0500 Original-Received: by mail-lb0-f174.google.com with SMTP id 10so13189922lbg.5 for ; Wed, 17 Dec 2014 11:49:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=uyOSbCt2bpEL4w7XOIEBGHo8AHoFac0P5N5vOYyTOPw=; b=JaZB4tRdCJBxzsDYWrggl3SeA4w+H4H6iz1xM7Rza/vzaN7gV+qifBjkpjrK83qrjS 36ClDb42nSNo5awf1u4XFHkZkJsXswDXa8q2PDCs38uc/hXvURkhxfXPbiPvtH0RQzVX OUs1Wp68Hm1MPhMpbjpx7tEHhnW4nReASVty69XV1vYu/+HjzB7BjtWbQfetbwaVI/HY 0K7iNWdYT9/Jy4elI7uLuRBFqxkhUtfmdnEv2E4/OSFcGR0/9xXqijroUnWu+YnVKwiw FWk06D6dN0FvZgkKzrnfzDJxlL+s1qxwV7w3lPbU5GD1tZCAtYaOXpxlADhbel7WJhjE zeIQ== X-Received: by 10.152.44.167 with SMTP id f7mr43476715lam.30.1418845769092; Wed, 17 Dec 2014 11:49:29 -0800 (PST) Original-Received: from leviafan (128-74-165-237.broadband.corbina.ru. [128.74.165.237]) by mx.google.com with ESMTPSA id ap3sm1165883lbc.48.2014.12.17.11.49.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Dec 2014 11:49:28 -0800 (PST) In-Reply-To: (Luca Ferrari's message of "Wed, 17 Dec 2014 10:07:20 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22e X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101645 Archived-At: Luca Ferrari (2014-12-17 12:07 +0300) wrote: > Hi all, > I'm trying to write down a simpler configuration for connecting to a > few database: > > (setq sql-connection-alist > '((TEST (sql-product 'postgres) > (sql-port 5432) > (sql-server "localhost") > (sql-user "demo") > (sql-password "demo") > (sql-database "demodb")) > (PROD (sql-product 'postgres) > (setq sql-port 5432) > (sql-user "demo") > (sql-password "demo") > (sql-database "demodb") ) ) ) > > > (defun pg-connect (which) > (interactive "sWhich database?" ) > (setq sql-product 'postgres) > (let () > (message "Connecting to %s" which) > (sql-connect which ) ) ) > > > The problem is that no matter what connection name I pass to > pg-connect, it always answers me that "SQL Connection does not > exist". > I suspect the problem is that sql-connect expects a symbol, but even > wrapping "which" with (symbol-name) does not help. > What am I missing? No the problem is not in a symbol - a string should work. At least I've tested your code and it worked. Are you sure "sql-connection-alist" contains the value you expect? Also do you really need your "pg-connect"? You can just use "M-x sql-connect". However if you needed it, you may take an "interactive" part of `sql-connect' to make completions available, so your function may look like this: (defun pg-connect (which) (interactive (list (sql-read-connection "Which database? "))) (message "Connecting to %S" which) (sql-connect which)) -- Alex