emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel sql code block issue and patch proposal
@ 2011-03-03 11:23 Alain Clément
  2011-03-03 13:11 ` Eric Schulte
  0 siblings, 1 reply; 7+ messages in thread
From: Alain Clément @ 2011-03-03 11:23 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 697 bytes --]

Hi everyone,

The =org-babel-temp-file= string seems to be escaped with backslashes on
some platforms (like MacOSX), which is not very appreciated by the =mysql
-e= command. I suggest the following patch for =ob-sql.el= (Org-mode Version
7.4 (release_7.4.590.g85d4d)):

74c74
<                     ('mysql (format "mysql %s < %s > %s"
---
>                     ('mysql (format "mysql %s -e \"source %s\" > %s"

Best regards,
-- Alain

-- 



Alain Clément
Dr ès sc. mathématiques

Université de Lausanne
Quartier UNIL-Centre
Bâtiment Unicentre
Bureau 339
CH-1015 Lausanne

T. +41 21 692 20 36 (direct)
T. +41 21 692 20 60 (secrétariat)

alain.clement@unil.ch

[-- Attachment #1.2: Type: text/html, Size: 1132 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

-- 
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Babel sql code block issue and patch proposal
  2011-03-03 11:23 Babel sql code block issue and patch proposal Alain Clément
@ 2011-03-03 13:11 ` Eric Schulte
  2011-03-03 19:34   ` Alain Clément
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2011-03-03 13:11 UTC (permalink / raw)
  To: Alain Clément; +Cc: emacs-orgmode

Hi Alain,

Does the following alternative fix work for you?

#+begin_src diff
  Changes in HEAD
          Modified lisp/ob-sql.el
  diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
  index 364070e..604d444 100644
  --- a/lisp/ob-sql.el
  +++ b/lisp/ob-sql.el
  @@ -71,7 +71,7 @@ This function is called by `org-babel-execute-src-block'."
                                        (or cmdline "")
                                        (org-babel-process-file-name in-file)
                                        (org-babel-process-file-name out-file)))
  -                    ('mysql (format "mysql %s -e \"source %s\" > %s"
  +                    ('mysql (format "mysql %s -e 'source %s' > %s"
                                       (or cmdline "")
                                      (org-babel-process-file-name in-file)
                                      (org-babel-process-file-name out-file)))
#+end_src

Also, just out of curiosity would you mind sharing an example result of
`org-babel-temporary-directory' which contains backslashes?

Thanks -- Eric

Alain Clément <alain.clement@unil.ch> writes:

> Hi everyone,
>
> The =org-babel-temp-file= string seems to be escaped with backslashes on
> some platforms (like MacOSX), which is not very appreciated by the =mysql
> -e= command. I suggest the following patch for =ob-sql.el= (Org-mode Version
> 7.4 (release_7.4.590.g85d4d)):
>
> 74c74
> <                     ('mysql (format "mysql %s < %s > %s"
> ---
>>                     ('mysql (format "mysql %s -e \"source %s\" > %s"
>
> Best regards,
> -- Alain
>
> -- 
>
>
>
> Alain Clément
> Dr ès sc. mathématiques
>
> Université de Lausanne
> Quartier UNIL-Centre
> Bâtiment Unicentre
> Bureau 339
> CH-1015 Lausanne
>
> T. +41 21 692 20 36 (direct)
> T. +41 21 692 20 60 (secrétariat)
>
> alain.clement@unil.ch

--
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Babel sql code block issue and patch proposal
  2011-03-03 13:11 ` Eric Schulte
@ 2011-03-03 19:34   ` Alain Clément
  2011-03-03 19:51     ` Eric Schulte
  0 siblings, 1 reply; 7+ messages in thread
From: Alain Clément @ 2011-03-03 19:34 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2646 bytes --]

Hi Eric,

Thanks for your prompt answer! Actually, it doesn't work since mysql
interprets backslashes as options, even between quotes. The value of my
`org-babel-temporary-directory' is
"/var/folders/9E/9EMu+g0oHBSrq-h9sX6i1U+++TM/-Tmp-/babel-86766893", but
"+"'s are escaped with a backslash at some stage.

Thanks,
- Alain

2011/3/3 Eric Schulte <schulte.eric@gmail.com>

> Hi Alain,
>
> Does the following alternative fix work for you?
>
> #+begin_src diff
>  Changes in HEAD
>          Modified lisp/ob-sql.el
>  diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
>  index 364070e..604d444 100644
>  --- a/lisp/ob-sql.el
>  +++ b/lisp/ob-sql.el
>  @@ -71,7 +71,7 @@ This function is called by
> `org-babel-execute-src-block'."
>                                        (or cmdline "")
>                                        (org-babel-process-file-name
> in-file)
>                                        (org-babel-process-file-name
> out-file)))
>  -                    ('mysql (format "mysql %s -e \"source %s\" > %s"
>  +                    ('mysql (format "mysql %s -e 'source %s' > %s"
>                                       (or cmdline "")
>                                      (org-babel-process-file-name in-file)
>                                      (org-babel-process-file-name
> out-file)))
> #+end_src
>
> Also, just out of curiosity would you mind sharing an example result of
> `org-babel-temporary-directory' which contains backslashes?
>
> Thanks -- Eric
>
> Alain Clément <alain.clement@unil.ch> writes:
>
> > Hi everyone,
> >
> > The =org-babel-temp-file= string seems to be escaped with backslashes on
> > some platforms (like MacOSX), which is not very appreciated by the =mysql
> > -e= command. I suggest the following patch for =ob-sql.el= (Org-mode
> Version
> > 7.4 (release_7.4.590.g85d4d)):
> >
> > 74c74
> > <                     ('mysql (format "mysql %s < %s > %s"
> > ---
> >>                     ('mysql (format "mysql %s -e \"source %s\" > %s"
> >
> > Best regards,
> > -- Alain
> >
> > --
> >
> >
> >
> > Alain Clément
> > Dr ès sc. mathématiques
> >
> > Université de Lausanne
> > Quartier UNIL-Centre
> > Bâtiment Unicentre
> > Bureau 339
> > CH-1015 Lausanne
> >
> > T. +41 21 692 20 36 (direct)
> > T. +41 21 692 20 60 (secrétariat)
> >
> > alain.clement@unil.ch
>



-- 



Alain Clément
Dr ès sc. mathématiques

Université de Lausanne
Quartier UNIL-Centre
Bâtiment Unicentre
Bureau 339
CH-1015 Lausanne

T. +41 21 692 20 36 (direct)
T. +41 21 692 20 60 (secrétariat)

alain.clement@unil.ch

[-- Attachment #2: Type: text/html, Size: 3893 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Babel sql code block issue and patch proposal
  2011-03-03 19:34   ` Alain Clément
@ 2011-03-03 19:51     ` Eric Schulte
  2011-03-07  9:15       ` Alain Clément
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2011-03-03 19:51 UTC (permalink / raw)
  To: Alain Clément; +Cc: emacs-orgmode

Hi Alain,

Would the following work (escaping "-"s with a backslash)?

#+begin_src diff
  diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
  index 364070e..838f013 100644
  --- a/lisp/ob-sql.el
  +++ b/lisp/ob-sql.el
  @@ -73,7 +73,9 @@ This function is called by `org-babel-execute-src-block'."
                                        (org-babel-process-file-name out-file)))
                       ('mysql (format "mysql %s -e \"source %s\" > %s"
                                       (or cmdline "")
  -				    (org-babel-process-file-name in-file)
  +				    (replace-regexp-in-string
  +				     "\\-" "\\\\-"
  +				     (org-babel-process-file-name in-file))
                                      (org-babel-process-file-name out-file)))
                      ('postgresql (format
                                    "psql -A -P footer=off -F \"\t\"  -f %s -o %s %s"
#+end_src

Best -- Eric

Alain Clément <alain.clement@unil.ch> writes:

> Hi Eric,
>
> Thanks for your prompt answer! Actually, it doesn't work since mysql interprets backslashes as options, even between quotes. The value of my
> `org-babel-temporary-directory' is "/var/folders/9E/9EMu+g0oHBSrq-h9sX6i1U+++TM/-Tmp-/babel-86766893", but "+"'s are escaped with a backslash at some stage.
>
> Thanks,
> - Alain
>
> 2011/3/3 Eric Schulte <schulte.eric@gmail.com>
>
>     Hi Alain,
>    
>     Does the following alternative fix work for you?
>
> #+begin_src diff<br>
>  Changes in HEAD<br>
>      Modified lisp/ob-sql.el<br>
>  diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el<br>
>  index 364070e..604d444 100644<br>
>  --- a/lisp/ob-sql.el<br>
>  +++ b/lisp/ob-sql.el<br>
>  @@ -71,7 +71,7 @@ This function is called by `org-babel-execute-src-block&#39;.&quot;<br>
>                     (or cmdline &quot;&quot;)<br>
>                     (org-babel-process-file-name in-file)<br>
>                     (org-babel-process-file-name out-file)))<br>
>  -          (&#39;mysql (format &quot;mysql %s -e \&quot;source %s\&quot; &gt; %s&quot;<br>
>  +          (&#39;mysql (format &quot;mysql %s -e &#39;source %s&#39; &gt; %s&quot;<br>
>                     (or cmdline &quot;&quot;)<br>
>                    (org-babel-process-file-name in-file)<br>
>                    (org-babel-process-file-name out-file)))<br>
> #+end_src<br>
> Also, just out of curiosity would you mind sharing an example result of
> `org-babel-temporary-directory' which contains backslashes?
>
> Thanks -- Eric
>
> Alain Cl?ment <alain.clement@unil.ch> writes:
>
>> Hi everyone,
>>
>> The =org-babel-temp-file= string seems to be escaped with backslashes on
>> some platforms (like MacOSX), which is not very appreciated by the =mysql
>> -e= command. I suggest the following patch for =ob-sql.el= (Org-mode Version
>> 7.4 (release_7.4.590.g85d4d)):
>>
>> 74c74
>> < ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s < %s > %s"
>> ---
>>> ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s -e \"source %s\" > %s"
>>
>> Best regards,
>> -- Alain
>>
>> --
>>
>>
>>
>> Alain Cl?ment
>> Dr ?s sc. math?matiques
>>
>> Universit? de Lausanne
>> Quartier UNIL-Centre
>> B?timent Unicentre
>> Bureau 339
>> CH-1015 Lausanne
>>
>> T. +41 21 692 20 36 (direct)
>> T. +41 21 692 20 60 (secr?tariat)
>>
>> alain.clement@unil.ch
>
> --
>
> [lo_unil05_bleu]             
>
> Alain Cl?ment
> Dr ?s sc. math?matiques
>
> Universit? de Lausanne
> Quartier UNIL-Centre
> B?timent Unicentre
> Bureau 339
> CH-1015 Lausanne
>
> T. +41 21 692 20 36 (direct)
> T. +41 21 692 20 60 (secr?tariat)
>
> alain.clement@unil.ch

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Babel sql code block issue and patch proposal
  2011-03-03 19:51     ` Eric Schulte
@ 2011-03-07  9:15       ` Alain Clément
  2011-03-07 15:33         ` Eric Schulte
  0 siblings, 1 reply; 7+ messages in thread
From: Alain Clément @ 2011-03-07  9:15 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 5001 bytes --]

Hi Eric,
Thanks for your message and sorry for the delay.
Actually, escaping characters with backslashes is the problem within mysql
when the =SOURCE= command is invoqued. To believe the forums, it seems that
this difficulty is well known among mysql users. The suggested solution
there consists in piping the file content via the standard input of the
mysql command instead of making use of the =SOURCE= command. In other words,
let the shell do the job of finding the file as mysql can't. My initial
suggestion for a patch relies on this conclusion and seems to work well. Now
it's time to stop my own advertising and ask you about the cons of such a
patch.
Best regards and thank you again.
- Alain

2011/3/3 Eric Schulte <schulte.eric@gmail.com>

> Hi Alain,
>
> Would the following work (escaping "-"s with a backslash)?
>
> #+begin_src diff
>   diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
>   index 364070e..838f013 100644
>   --- a/lisp/ob-sql.el
>  +++ b/lisp/ob-sql.el
>   @@ -73,7 +73,9 @@ This function is called by
> `org-babel-execute-src-block'."
>                                         (org-babel-process-file-name
> out-file)))
>                       ('mysql (format "mysql %s -e \"source %s\" > %s"
>                                       (or cmdline "")
>  -                                 (org-babel-process-file-name in-file)
>   +                                 (replace-regexp-in-string
>  +                                  "\\-" "\\\\-"
>  +                                  (org-babel-process-file-name in-file))
>                                       (org-babel-process-file-name
> out-file)))
>                       ('postgresql (format
>                                    "psql -A -P footer=off -F \"\t\"  -f %s
> -o %s %s"
> #+end_src
>
> Best -- Eric
>
> Alain Clément <alain.clement@unil.ch> writes:
>
> > Hi Eric,
> >
> > Thanks for your prompt answer! Actually, it doesn't work since mysql
> interprets backslashes as options, even between quotes. The value of my
> > `org-babel-temporary-directory' is
> "/var/folders/9E/9EMu+g0oHBSrq-h9sX6i1U+++TM/-Tmp-/babel-86766893", but
> "+"'s are escaped with a backslash at some stage.
> >
> > Thanks,
> > - Alain
> >
> > 2011/3/3 Eric Schulte <schulte.eric@gmail.com>
> >
> >     Hi Alain,
> >
> >     Does the following alternative fix work for you?
> >
> > #+begin_src diff<br>
> >  Changes in HEAD<br>
> >      Modified lisp/ob-sql.el<br>
> >  diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el<br>
> >  index 364070e..604d444 100644<br>
> >  --- a/lisp/ob-sql.el<br>
> >  +++ b/lisp/ob-sql.el<br>
> >  @@ -71,7 +71,7 @@ This function is called by
> `org-babel-execute-src-block&#39;.&quot;<br>
> >                     (or cmdline &quot;&quot;)<br>
> >                     (org-babel-process-file-name in-file)<br>
> >                     (org-babel-process-file-name out-file)))<br>
> >  -          (&#39;mysql (format &quot;mysql %s -e \&quot;source %s\&quot;
> &gt; %s&quot;<br>
> >  +          (&#39;mysql (format &quot;mysql %s -e &#39;source %s&#39;
> &gt; %s&quot;<br>
> >                     (or cmdline &quot;&quot;)<br>
> >                    (org-babel-process-file-name in-file)<br>
> >                    (org-babel-process-file-name out-file)))<br>
> > #+end_src<br>
> > Also, just out of curiosity would you mind sharing an example result of
> > `org-babel-temporary-directory' which contains backslashes?
> >
> > Thanks -- Eric
> >
> > Alain Cl?ment <alain.clement@unil.ch> writes:
> >
> >> Hi everyone,
> >>
> >> The =org-babel-temp-file= string seems to be escaped with backslashes on
> >> some platforms (like MacOSX), which is not very appreciated by the
> =mysql
> >> -e= command. I suggest the following patch for =ob-sql.el= (Org-mode
> Version
> >> 7.4 (release_7.4.590.g85d4d)):
> >>
> >> 74c74
> >> < ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s < %s > %s"
> >> ---
> >>> ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s -e \"source %s\" > %s"
> >>
> >> Best regards,
> >> -- Alain
> >>
> >> --
> >>
> >>
> >>
> >> Alain Cl?ment
> >> Dr ?s sc. math?matiques
> >>
> >> Universit? de Lausanne
> >> Quartier UNIL-Centre
> >> B?timent Unicentre
> >> Bureau 339
> >> CH-1015 Lausanne
> >>
> >> T. +41 21 692 20 36 (direct)
> >> T. +41 21 692 20 60 (secr?tariat)
> >>
> >> alain.clement@unil.ch
> >
> > --
> >
> > [lo_unil05_bleu]
> >
> > Alain Cl?ment
> > Dr ?s sc. math?matiques
> >
> > Universit? de Lausanne
> > Quartier UNIL-Centre
> > B?timent Unicentre
> > Bureau 339
> > CH-1015 Lausanne
> >
> > T. +41 21 692 20 36 (direct)
> > T. +41 21 692 20 60 (secr?tariat)
> >
> > alain.clement@unil.ch
>



-- 



Alain Clément
Dr ès sc. mathématiques

Université de Lausanne
Quartier UNIL-Centre
Bâtiment Unicentre
Bureau 339
CH-1015 Lausanne

T. +41 21 692 20 36 (direct)
T. +41 21 692 20 60 (secrétariat)

alain.clement@unil.ch

[-- Attachment #2: Type: text/html, Size: 7190 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Babel sql code block issue and patch proposal
  2011-03-07  9:15       ` Alain Clément
@ 2011-03-07 15:33         ` Eric Schulte
  2011-03-07 16:24           ` Alain Clément
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Schulte @ 2011-03-07 15:33 UTC (permalink / raw)
  To: Alain Clément; +Cc: emacs-orgmode

To be honest, I don't have any overly motivating reasons for passing the
file name to mysql rather than piping the contents of the file.  Aside
from consistency with the other SQL engines, the nagging feeling that
things are the way they are for a reason, and a healthy fear of the new
and unknown.  However development is not for cowards, I've applied your
suggestion, and mysql is now reading input through stdin.

Best -- Eric

Alain Clément <alain.clement@unil.ch> writes:

> Hi Eric,
> Thanks for your message and sorry for the delay.
> Actually, escaping characters with backslashes is the problem within mysql when the =SOURCE= command is invoqued. To believe the forums, it seems that this difficulty is well
> known among mysql users. The suggested solution there consists in piping the file content via the standard input of the mysql command instead of making use of the =SOURCE=
> command. In other words, let the shell do the job of finding the file as mysql can't. My initial suggestion for a patch relies on this conclusion and seems to work well. Now
> it's time to stop my own advertising and ask you about the cons of such a patch.
> Best regards and thank you again.
> - Alain
>
> 2011/3/3 Eric Schulte <schulte.eric@gmail.com>
>
>     Hi Alain,
>    
>     Would the following work (escaping "-"s with a backslash)?
>
> #+begin_src diff<br>
> <div> diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el<br>
> </div> index 364070e..838f013 100644<br>
> <div> --- a/lisp/ob-sql.el<br>
>  +++ b/lisp/ob-sql.el<br>
> </div> @@ -73,7 +73,9 @@ This function is called by `org-babel-execute-src-block&#39;.&quot;<br>
> <div>                    (org-babel-process-file-name out-file)))<br>
>             (&#39;mysql (format &quot;mysql %s -e \&quot;source %s\&quot; &gt; %s&quot;<br>
>                     (or cmdline &quot;&quot;)<br>
>  -                 (org-babel-process-file-name in-file)<br>
> </div> +                 (replace-regexp-in-string<br>
>  +                 &quot;\\-&quot; &quot;\\\\-&quot;<br>
>  +                 (org-babel-process-file-name in-file))<br>
> <div>                   (org-babel-process-file-name out-file)))<br>
> </div>           (&#39;postgresql (format<br>
>                   &quot;psql -A -P footer=off -F \&quot;\t\&quot; -f %s -o %s %s&quot;<br>
> #+end_src<br>
> Best -- Eric
>
> Alain Cl?ment <alain.clement@unil.ch> writes:
>
>> Hi Eric,
>>
>> Thanks for your prompt answer! Actually, it doesn't work since mysql interprets backslashes as options, even between quotes. The value of my
>> `org-babel-temporary-directory' is "/var/folders/9E/9EMu+g0oHBSrq-h9sX6i1U+++TM/-Tmp-/babel-86766893", but "+"'s are escaped with a backslash at some stage.
>>
>> Thanks,
>> - Alain
>>
>> 2011/3/3 Eric Schulte <schulte.eric@gmail.com>
>>
>> ? ? Hi Alain,
>>
>> ? ? Does the following alternative fix work for you?
>>
>> #+begin_src diff<br>
>> ?Changes in HEAD<br>
>> ? ? ?Modified lisp/ob-sql.el<br>
>> ?diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el<br>
>> ?index 364070e..604d444 100644<br>
>> ?--- a/lisp/ob-sql.el<br>
>> ?+++ b/lisp/ob-sql.el<br>
>> ?@@ -71,7 +71,7 @@ This function is called by `org-babel-execute-src-block&#39;.&quot;<br>
>> ? ? ? ? ? ? ? ? ? ? (or cmdline &quot;&quot;)<br>
>> ? ? ? ? ? ? ? ? ? ? (org-babel-process-file-name in-file)<br>
>> ? ? ? ? ? ? ? ? ? ? (org-babel-process-file-name out-file)))<br>
>> ?- ? ? ? ? ?(&#39;mysql (format &quot;mysql %s -e \&quot;source %s\&quot; &gt; %s&quot;<br>
>> ?+ ? ? ? ? ?(&#39;mysql (format &quot;mysql %s -e &#39;source %s&#39; &gt; %s&quot;<br>
>> ? ? ? ? ? ? ? ? ? ? (or cmdline &quot;&quot;)<br>
>> ? ? ? ? ? ? ? ? ? ?(org-babel-process-file-name in-file)<br>
>> ? ? ? ? ? ? ? ? ? ?(org-babel-process-file-name out-file)))<br>
>> #+end_src<br>
>> Also, just out of curiosity would you mind sharing an example result of
>> `org-babel-temporary-directory' which contains backslashes?
>>
>> Thanks -- Eric
>>
>> Alain Cl?ment <alain.clement@unil.ch> writes:
>>
>>> Hi everyone,
>>>
>>> The =org-babel-temp-file= string seems to be escaped with backslashes on
>>> some platforms (like MacOSX), which is not very appreciated by the =mysql
>>> -e= command. I suggest the following patch for =ob-sql.el= (Org-mode Version
>>> 7.4 (release_7.4.590.g85d4d)):
>>>
>>> 74c74
>>> < ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s < %s > %s"
>>> ---
>>>> ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s -e \"source %s\" > %s"
>>>
>>> Best regards,
>>> -- Alain
>>>
>>> --
>>>
>>>
>>>
>>> Alain Cl?ment
>>> Dr ?s sc. math?matiques
>>>
>>> Universit? de Lausanne
>>> Quartier UNIL-Centre
>>> B?timent Unicentre
>>> Bureau 339
>>> CH-1015 Lausanne
>>>
>>> T. +41 21 692 20 36 (direct)
>>> T. +41 21 692 20 60 (secr?tariat)
>>>
>>> alain.clement@unil.ch
>>
>> --
>>
>> [lo_unil05_bleu]
>>
>> Alain Cl?ment
>> Dr ?s sc. math?matiques
>>
>> Universit? de Lausanne
>> Quartier UNIL-Centre
>> B?timent Unicentre
>> Bureau 339
>> CH-1015 Lausanne
>>
>> T. +41 21 692 20 36 (direct)
>> T. +41 21 692 20 60 (secr?tariat)
>>
>> alain.clement@unil.ch
>
> --
>
> [lo_unil05_bleu]             
>
> Alain Cl?ment
> Dr ?s sc. math?matiques
>
> Universit? de Lausanne
> Quartier UNIL-Centre
> B?timent Unicentre
> Bureau 339
> CH-1015 Lausanne
>
> T. +41 21 692 20 36 (direct)
> T. +41 21 692 20 60 (secr?tariat)
>
> alain.clement@unil.ch

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Babel sql code block issue and patch proposal
  2011-03-07 15:33         ` Eric Schulte
@ 2011-03-07 16:24           ` Alain Clément
  0 siblings, 0 replies; 7+ messages in thread
From: Alain Clément @ 2011-03-07 16:24 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 6235 bytes --]

Hi Eric,
Thank you so much, your "fearless development" is great and very
appreciated!
Best regards,
- Alain

2011/3/7 Eric Schulte <schulte.eric@gmail.com>

> To be honest, I don't have any overly motivating reasons for passing the
> file name to mysql rather than piping the contents of the file.  Aside
> from consistency with the other SQL engines, the nagging feeling that
> things are the way they are for a reason, and a healthy fear of the new
> and unknown.  However development is not for cowards, I've applied your
> suggestion, and mysql is now reading input through stdin.
>
> Best -- Eric
>
> Alain Clément <alain.clement@unil.ch> writes:
>
> > Hi Eric,
> > Thanks for your message and sorry for the delay.
> > Actually, escaping characters with backslashes is the problem within
> mysql when the =SOURCE= command is invoqued. To believe the forums, it seems
> that this difficulty is well
> > known among mysql users. The suggested solution there consists in piping
> the file content via the standard input of the mysql command instead of
> making use of the =SOURCE=
> > command. In other words, let the shell do the job of finding the file as
> mysql can't. My initial suggestion for a patch relies on this conclusion and
> seems to work well. Now
> > it's time to stop my own advertising and ask you about the cons of such a
> patch.
> > Best regards and thank you again.
> > - Alain
> >
> > 2011/3/3 Eric Schulte <schulte.eric@gmail.com>
> >
> >     Hi Alain,
> >
> >     Would the following work (escaping "-"s with a backslash)?
> >
> > #+begin_src diff<br>
> > <div> diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el<br>
> > </div> index 364070e..838f013 100644<br>
> > <div> --- a/lisp/ob-sql.el<br>
> >  +++ b/lisp/ob-sql.el<br>
> > </div> @@ -73,7 +73,9 @@ This function is called by
> `org-babel-execute-src-block&#39;.&quot;<br>
> > <div>                    (org-babel-process-file-name out-file)))<br>
> >             (&#39;mysql (format &quot;mysql %s -e \&quot;source %s\&quot;
> &gt; %s&quot;<br>
> >                     (or cmdline &quot;&quot;)<br>
> >  -                 (org-babel-process-file-name in-file)<br>
> > </div> +                 (replace-regexp-in-string<br>
> >  +                 &quot;\\-&quot; &quot;\\\\-&quot;<br>
> >  +                 (org-babel-process-file-name in-file))<br>
> > <div>                   (org-babel-process-file-name out-file)))<br>
> > </div>           (&#39;postgresql (format<br>
> >                   &quot;psql -A -P footer=off -F \&quot;\t\&quot; -f %s
> -o %s %s&quot;<br>
> > #+end_src<br>
> > Best -- Eric
> >
> > Alain Cl?ment <alain.clement@unil.ch> writes:
> >
> >> Hi Eric,
> >>
> >> Thanks for your prompt answer! Actually, it doesn't work since mysql
> interprets backslashes as options, even between quotes. The value of my
> >> `org-babel-temporary-directory' is
> "/var/folders/9E/9EMu+g0oHBSrq-h9sX6i1U+++TM/-Tmp-/babel-86766893", but
> "+"'s are escaped with a backslash at some stage.
> >>
> >> Thanks,
> >> - Alain
> >>
> >> 2011/3/3 Eric Schulte <schulte.eric@gmail.com>
> >>
> >> ? ? Hi Alain,
> >>
> >> ? ? Does the following alternative fix work for you?
> >>
> >> #+begin_src diff<br>
> >> ?Changes in HEAD<br>
> >> ? ? ?Modified lisp/ob-sql.el<br>
> >> ?diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el<br>
> >> ?index 364070e..604d444 100644<br>
> >> ?--- a/lisp/ob-sql.el<br>
> >> ?+++ b/lisp/ob-sql.el<br>
> >> ?@@ -71,7 +71,7 @@ This function is called by
> `org-babel-execute-src-block&#39;.&quot;<br>
> >> ? ? ? ? ? ? ? ? ? ? (or cmdline &quot;&quot;)<br>
> >> ? ? ? ? ? ? ? ? ? ? (org-babel-process-file-name in-file)<br>
> >> ? ? ? ? ? ? ? ? ? ? (org-babel-process-file-name out-file)))<br>
> >> ?- ? ? ? ? ?(&#39;mysql (format &quot;mysql %s -e \&quot;source
> %s\&quot; &gt; %s&quot;<br>
> >> ?+ ? ? ? ? ?(&#39;mysql (format &quot;mysql %s -e &#39;source %s&#39;
> &gt; %s&quot;<br>
> >> ? ? ? ? ? ? ? ? ? ? (or cmdline &quot;&quot;)<br>
> >> ? ? ? ? ? ? ? ? ? ?(org-babel-process-file-name in-file)<br>
> >> ? ? ? ? ? ? ? ? ? ?(org-babel-process-file-name out-file)))<br>
> >> #+end_src<br>
> >> Also, just out of curiosity would you mind sharing an example result of
> >> `org-babel-temporary-directory' which contains backslashes?
> >>
> >> Thanks -- Eric
> >>
> >> Alain Cl?ment <alain.clement@unil.ch> writes:
> >>
> >>> Hi everyone,
> >>>
> >>> The =org-babel-temp-file= string seems to be escaped with backslashes
> on
> >>> some platforms (like MacOSX), which is not very appreciated by the
> =mysql
> >>> -e= command. I suggest the following patch for =ob-sql.el= (Org-mode
> Version
> >>> 7.4 (release_7.4.590.g85d4d)):
> >>>
> >>> 74c74
> >>> < ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s < %s > %s"
> >>> ---
> >>>> ? ? ? ? ? ? ? ? ? ? ('mysql (format "mysql %s -e \"source %s\" > %s"
> >>>
> >>> Best regards,
> >>> -- Alain
> >>>
> >>> --
> >>>
> >>>
> >>>
> >>> Alain Cl?ment
> >>> Dr ?s sc. math?matiques
> >>>
> >>> Universit? de Lausanne
> >>> Quartier UNIL-Centre
> >>> B?timent Unicentre
> >>> Bureau 339
> >>> CH-1015 Lausanne
> >>>
> >>> T. +41 21 692 20 36 (direct)
> >>> T. +41 21 692 20 60 (secr?tariat)
> >>>
> >>> alain.clement@unil.ch
> >>
> >> --
> >>
> >> [lo_unil05_bleu]
> >>
> >> Alain Cl?ment
> >> Dr ?s sc. math?matiques
> >>
> >> Universit? de Lausanne
> >> Quartier UNIL-Centre
> >> B?timent Unicentre
> >> Bureau 339
> >> CH-1015 Lausanne
> >>
> >> T. +41 21 692 20 36 (direct)
> >> T. +41 21 692 20 60 (secr?tariat)
> >>
> >> alain.clement@unil.ch
> >
> > --
> >
> > [lo_unil05_bleu]
> >
> > Alain Cl?ment
> > Dr ?s sc. math?matiques
> >
> > Universit? de Lausanne
> > Quartier UNIL-Centre
> > B?timent Unicentre
> > Bureau 339
> > CH-1015 Lausanne
> >
> > T. +41 21 692 20 36 (direct)
> > T. +41 21 692 20 60 (secr?tariat)
> >
> > alain.clement@unil.ch
>



-- 



Alain Clément
Dr ès sc. mathématiques

Université de Lausanne
Quartier UNIL-Centre
Bâtiment Unicentre
Bureau 339
CH-1015 Lausanne

T. +41 21 692 20 36 (direct)
T. +41 21 692 20 60 (secrétariat)

alain.clement@unil.ch

[-- Attachment #2: Type: text/html, Size: 8961 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-07 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-03 11:23 Babel sql code block issue and patch proposal Alain Clément
2011-03-03 13:11 ` Eric Schulte
2011-03-03 19:34   ` Alain Clément
2011-03-03 19:51     ` Eric Schulte
2011-03-07  9:15       ` Alain Clément
2011-03-07 15:33         ` Eric Schulte
2011-03-07 16:24           ` Alain Clément

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).