From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Vorobiev Subject: Re: [Babel][R] Inclusion of multi-line named code blocks in R code Date: Wed, 18 Sep 2013 19:43:09 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11337ef6b50e1d04e6b1d7be Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMSLD-0000XK-H7 for emacs-orgmode@gnu.org; Wed, 18 Sep 2013 20:43:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMSLC-0006DS-2n for emacs-orgmode@gnu.org; Wed, 18 Sep 2013 20:43:31 -0400 Received: from mail-vb0-x231.google.com ([2607:f8b0:400c:c02::231]:47786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMSLB-0006DI-Tl for emacs-orgmode@gnu.org; Wed, 18 Sep 2013 20:43:30 -0400 Received: by mail-vb0-f49.google.com with SMTP id w16so5750597vbb.8 for ; Wed, 18 Sep 2013 17:43:29 -0700 (PDT) In-Reply-To: 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: emacs-orgmode --001a11337ef6b50e1d04e6b1d7be Content-Type: text/plain; charset=ISO-8859-1 Hi Tom, Unfortunately I can't have pure SQL output in my org files for two reasons: 1. The result set I am dealing with for this particular problem is about 20000 records 2. My SQL server (Netezza, "big data appliance") is not supported by Babel-SQL. I configured sql-mode to work with Netezza but session-based SQL is not supported by Babel either. I started adding support for SQL sessions to ob-sql.el and it kind of works but the results I am getting are inconsistent and only a small subset of header parameters is supported. Of course I haven't tested is with any other database. I can share what I've done if anybody is interested. Regards, Alex On Wed, Sep 18, 2013 at 5:27 PM, Thomas S. Dye wrote: > Aloha Alex, > > My work flow in this situation evaluates the SQL to create an Org-mode > table, which serves as input to the R source code block. > > For me, seeing the SQL output in a table is a sanity check. > > hth, > Tom > > Alexander Vorobiev writes: > > > I have R code which submits SQL statements to a database server. Since > the > > SQL is rather complex, I want to put it into a separate code block in > order > > to have proper formatting, syntax highlighting, etc: > > > > #+name: long-sql > > #+begin_src sql > > select * > > from many, tables > > where > > complex_condition1 = 1, > > complex_condition2 = 2 > > #+end_src > > > > * Load the data to R session > > #+begin_src R :session *R* :noweb yes > > result <- submit_query('<>') > > #+end_src > > > > Unfortunately, the R block doesn't work. When I open the file generated > by > > Babel, I see this: > > > > result <- submit_query('select * > > result <- submit_query('from many, tables > > etc > > > > instead of the one R submit_query call with my SQL statement as an > > argument. Is there anything I can do to achieve that? > > > > Thanks > > Alex > > I have R code which submits SQL statements to a database server. Since > > the SQL is rather complex, I want to put it into a separate code block > > in order to have proper formatting, syntax highlighting, etc: > > > > #+name: long-sql > > #+begin_src sql > > select * > > from many, tables > > where > > complex_condition1 = 1, > > complex_condition2 = 2 > > #+end_src > > > > * Load the data to R session > > #+begin_src R :session *R* :noweb yes > > result <- submit_query('<>') > > #+end_src > > > > Unfortunately, the R block doesn't work. When I open the file > > generated by Babel, I see this: > > > > result <- submit_query('select * > > result <- submit_query('from many, tables > > etc > > > > instead of the one R submit_query call with my SQL statement as an > > argument. Is there anything I can do to achieve that? > > > > Thanks > > Alex > > > > > > -- > Thomas S. Dye > http://www.tsdye.com > --001a11337ef6b50e1d04e6b1d7be Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Tom,

Unfortunately I can't have = pure SQL output in my org files for two reasons:

1= . The result set I am dealing with for this particular problem is about 200= 00 records
2. My SQL server (Netezza, "big data appliance") is not supp= orted by Babel-SQL. I configured sql-mode to work with Netezza but session-= based SQL is not supported by Babel either. I started adding support for SQ= L sessions to ob-sql.el and it kind of works but the results I am getting a= re inconsistent and only a small subset of header parameters is supported. = Of course I haven't tested is with any other database. I can share what= I've done if anybody is interested.

Regards,
Alex


On Wed, Sep 18, 2013 at 5:27 PM, = Thomas S. Dye <tsd@tsdye.com> wrote:
Aloha Alex,

My work flow in this situation evaluates the SQL to create an Org-mode
table, which serves as input to the R source code block.

For me, seeing the SQL output in a table is a sanity check.

hth,
Tom

Alexander Vorobiev <alex= ander.vorobiev@gmail.com> writes:

> I have R code which submits SQL statements to a database server. Since= the
> SQL is rather complex, I want to put it into a separate code block in = order
> to have proper formatting, syntax highlighting, etc:
>
> #+name: long-sql
> #+begin_src sql
> =A0 =A0 select *
> =A0 =A0 from many, tables
> =A0 =A0 where
> =A0 =A0 =A0 =A0 complex_condition1 =3D 1,
> =A0 =A0 =A0 =A0 complex_condition2 =3D 2
> #+end_src
>
> * Load the data to R session
> #+begin_src R :session *R* :noweb yes
> =A0 =A0 result <- submit_query('<<long-sql>>')<= br> > #+end_src
>
> Unfortunately, the R block doesn't work. When I open the file gene= rated by
> Babel, I see this:
>
> result <- submit_query('select *
> result <- submit_query('from many, tables
> etc
>
> instead of the one R submit_query call with my SQL statement as an
> argument. Is there anything I can do to achieve that?
>
> Thanks
> Alex
> I have R code which submits SQL statements to a database server. Since=
> the SQL is rather complex, I want to put it into a separate code block=
> in order to have proper formatting, syntax highlighting, etc:
>
> #+name: long-sql
> #+begin_src sql
> select *
> from many, tables
> where
> complex_condition1 =3D 1,
> complex_condition2 =3D 2
> #+end_src
>
> * Load the data to R session
> #+begin_src R :session *R* :noweb yes
> result <- submit_query('<<long-sql>>')
> #+end_src
>
> Unfortunately, the R block doesn't work. When I open the file
> generated by Babel, I see this:
>
> result <- submit_query('select *
> result <- submit_query('from many, tables
> etc
>
> instead of the one R submit_query call with my SQL statement as an
> argument. Is there anything I can do to achieve that?
>
> Thanks
> Alex
>
>

--
Thomas S. Dye
http://www.tsdye.com=

--001a11337ef6b50e1d04e6b1d7be--