emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dan Davison <dandavison7@gmail.com>
To: yesare <email.snr@gmail.com>
Cc: emacs-orgmode@gnu.org, Bastien <bastien.guerry@wikimedia.fr>
Subject: Re: Help with Babel and using SQL
Date: Sun, 13 Feb 2011 22:08:29 +0000	[thread overview]
Message-ID: <m1bp2f37vm.fsf@gmail.com> (raw)
In-Reply-To: <AANLkTimphKRetaW2C02XEoWHMZws81JQQh6KBKtQjMWy@mail.gmail.com> (yesare's message of "Sun, 13 Feb 2011 09:20:02 -0600")

yesare <email.snr@gmail.com> 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 <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> 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

      parent reply	other threads:[~2011-02-13 22:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-12 19:06 Help with Babel and using SQL yesare
2011-02-13  9:08 ` Bastien
2011-02-13 15:20   ` yesare
2011-02-13 18:21     ` Eric Schulte
2011-02-14  1:54       ` yesare
2011-02-13 22:08     ` Dan Davison [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1bp2f37vm.fsf@gmail.com \
    --to=dandavison7@gmail.com \
    --cc=bastien.guerry@wikimedia.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=email.snr@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).