From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Help with Babel and using SQL Date: Sun, 13 Feb 2011 22:08:29 +0000 Message-ID: References: <87ei7cpahv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=52126 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pok7R-0003EV-J9 for emacs-orgmode@gnu.org; Sun, 13 Feb 2011 17:08:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pok7Q-0007WV-Cz for emacs-orgmode@gnu.org; Sun, 13 Feb 2011 17:08:37 -0500 Received: from mail-ww0-f49.google.com ([74.125.82.49]:38648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pok7Q-0007WQ-1s for emacs-orgmode@gnu.org; Sun, 13 Feb 2011 17:08:36 -0500 Received: by wwb17 with SMTP id 17so4315455wwb.30 for ; Sun, 13 Feb 2011 14:08:35 -0800 (PST) In-Reply-To: (yesare's message of "Sun, 13 Feb 2011 09:20:02 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: yesare Cc: emacs-orgmode@gnu.org, Bastien yesare writes: > Thanks. > > I opened up ob-sql.el and read the code to see if I can figure it out. > > I think I have answered my first question. I wrote the following and hit > C-c C-c and I got the result set back. > > #+srcname: sampsql > #+begin_src sql :engine mysql :cmdline -h hostname -u username -pmypass -D > dbname > select * from tablename; > #+end_src > > regarding my 2nd question (reading orgtables), I am thinking that one can't > read orgtables in the same way as you read a db table. But you can use an > org table to extract data snippets to pass as variables to a sql or build a > dynamic sql. Is my understanding correct? I'm not sure yet. Could you give a concrete example of something that you think is not possible? Then it shouldn't be too hard for us to say whether it is or isn't possible. > I was also experimenting on passing variables. I modified the above example > as shown below but I did not get any results I'm not the best person to help here (Eric Schulte and Seb Vauban would know more about using babel with sql) but your example does seem to work to me. If I put point on the block and issue C-c C-v C-v (org-babel-expand-src-block), then I see select * from tablename; but if I get rid of the :var then I see select * from $table; demonstrating that the :var substitution has been performed What do you get when you expand the block? Dan > > #+srcname: sampsql > #+begin_src sql :engine mysql :cmdline -h hostname -u username -pmypass -D > dbname :var table="tablename" > select * from $table; > #+end_src > > > > > > > > On Sun, Feb 13, 2011 at 3:08 AM, Bastien wrote: > >> Hi Yesare, >> >> I'm not familiar enough with Babel to give you useful guidance, >> but others on the list may help you. >> >> yesare writes: >> >> > I am trying to do two things. >> > >> > >> > 1. Query a mysql or oracle table and post results in orgtable format >> > 2. Select data from an existing orgtable in current buffer and do >> > further processing with them (example: insert them into Oracle). >> > >> > I am sorry if this is vague but I am just looking for some initial >> > guidance on how to get around. >> >> Can you post the code your tried? What you expected? What happened >> instead? This will help people to know where and why you're stuck. >> >> Thanks! >> >> -- >> Bastien >> > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode