emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Help with Babel and using SQL


From: Dan Davison
Subject: [Orgmode] Re: Help with Babel and using SQL
Date: Sun, 13 Feb 2011 22:08:29 +0000
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (darwin)

yesare <address@hidden> 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 <address@hidden>wrote:
>
>> Hi Yesare,
>>
>> I'm not familiar enough with Babel to give you useful guidance,
>> but others on the list may help you.
>>
>> yesare <address@hidden> 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.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]