From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xi Shen Subject: Re: Is it possible to pass variable to variables of src block? Date: Tue, 12 Dec 2017 06:30:01 +0000 Message-ID: References: <877eu0gq3p.fsf@luisa.c0t0d0s0.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c0c89987af32805601ec87d" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOe51-00069C-At for emacs-orgmode@gnu.org; Tue, 12 Dec 2017 01:30:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOe50-000135-7p for emacs-orgmode@gnu.org; Tue, 12 Dec 2017 01:30:15 -0500 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]:33177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eOe4z-000110-VH for emacs-orgmode@gnu.org; Tue, 12 Dec 2017 01:30:14 -0500 Received: by mail-lf0-x234.google.com with SMTP id 74so21935904lfs.0 for ; Mon, 11 Dec 2017 22:30:13 -0800 (PST) In-Reply-To: <877eu0gq3p.fsf@luisa.c0t0d0s0.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Michael Welle Cc: emacs-orgmode@gnu.org --94eb2c0c89987af32805601ec87d Content-Type: text/plain; charset="UTF-8" Hi Michael, Yes, I think this is a way to my previous question. But what I really want to achieve is to loop through a list of server names and execute a script on them. Say I have 20 different database server. How can I do a loop with each server? Regards, David On Wed, Dec 6, 2017 at 5:34 PM Michael Welle wrote: > Hello, > > Xi Shen writes: > > > Hi, > > > > http://orgmode.org/manual/var.html > > > > This wiki explains how to use variable inside a src block. But I wonder > if > > it is possible to specify variable to the variables in the src > definition. > > > > E.g. for the sql src block, I want to execute a script on different > server. > > I want to define a variable for the ":dbhost" variable. > did you think about something like this? > > > (setq hmw/dbhost "db1") > > #+BEGIN_SRC sql :dbhost (symbol-value 'hmw/dbhost) :dbuser weather > :database environment :engine postgresql > select time, temperature from weather limit 20; > #+END_SRC > > Regards > hmw > > --94eb2c0c89987af32805601ec87d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Michael,

Yes, I think this is a way = to my previous question. But what I really want to achieve is to loop throu= gh a list of server names and execute a script on them.

Say I have 20 different database server. How can I do a loop with eac= h server?


Regards,
David<= /div>


O= n Wed, Dec 6, 2017 at 5:34 PM Michael Welle <mwe012008@gmx.net> wrote:
Hello,

Xi Shen <davi= dshen84@gmail.com> writes:

> Hi,
>
> http://orgmode.org/manual/var.html
>
> This wiki explains how to use variable inside a src block. But I wonde= r if
> it is possible to specify variable to the variables in the src definit= ion.
>
> E.g. for the sql src block, I want to execute a script on different se= rver.
> I want to define a variable for the ":dbhost" variable.
did you think about something like this?


(setq hmw/dbhost "db1")

#+BEGIN_SRC sql :dbhost (symbol-value 'hmw/dbhost) :dbuser weather :dat= abase environment :engine postgresql
select time, temperature from weather limit 20;
#+END_SRC

Regards
hmw

--94eb2c0c89987af32805601ec87d--