From mboxrd@z Thu Jan 1 00:00:00 1970 From: yesare Subject: Re: Help with Babel and using SQL Date: Sun, 13 Feb 2011 09:20:02 -0600 Message-ID: References: <87ei7cpahv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0838649271==" Return-path: Received: from [140.186.70.92] (port=59416 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PodkP-0007P2-3c for emacs-orgmode@gnu.org; Sun, 13 Feb 2011 10:20:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PodkN-0004Ru-9p for emacs-orgmode@gnu.org; Sun, 13 Feb 2011 10:20:24 -0500 Received: from mail-wy0-f169.google.com ([74.125.82.169]:41188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PodkN-0004Rh-1L for emacs-orgmode@gnu.org; Sun, 13 Feb 2011 10:20:23 -0500 Received: by wyj26 with SMTP id 26so4100352wyj.0 for ; Sun, 13 Feb 2011 07:20:22 -0800 (PST) In-Reply-To: <87ei7cpahv.fsf@gnu.org> 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: Bastien Cc: emacs-orgmode@gnu.org --===============0838649271== Content-Type: multipart/alternative; boundary=0016e64c1cf0464284049c2b7803 --0016e64c1cf0464284049c2b7803 Content-Type: text/plain; charset=ISO-8859-1 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 was also experimenting on passing variables. I modified the above example as shown below but I did not get any results #+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 > --0016e64c1cf0464284049c2b7803 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks. =A0

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 questio= n. =A0I wrote the following and hit C-c C-c and I got the result set back.<= /div>

#+srcname: sampsql
#+begin_src sql :engi= ne mysql :cmdline -h hostname -u username -pmypass -D dbname
sele= ct * 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. =A0But you can use an or= g table to extract data snippets to pass as variables to a sql or build a d= ynamic sql. Is my understanding correct?


I was also experimenting on passing vari= ables. =A0I modified the above example as shown below but I did not get any= results

#+srcname: sampsql
#+begin= _src sql :engine mysql :cmdline -h hostname -u username -pmypass -D dbname= =A0:var table=3D"tablename"
select * from $table;
#+end_src







On Sun, Feb 13, 2011 at 3:08 AM, Ba= stien <= bastien.guerry@wikimedia.fr> wrote:
Hi Yesare,

I'm not familiar enough with Babel to give you useful guidance,
but others on the list may help you.

yesare <email.snr@gmail.com&g= t; writes:

> I am trying to do two things.
> =A0
>
> =A01. Query a mysql or oracle table and post results in orgtable= format
> =A02. Select data from=A0an existing orgtable in current buffer and=A0= do
> =A0 =A0 further processing with them (example: inser= t 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? =A0What you expected? =A0What happe= ned
instead? =A0 This will help people to know where and why you're stuck.<= br>
Thanks!

--
=A0Bastien

--0016e64c1cf0464284049c2b7803-- --===============0838649271== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============0838649271==--