On Feb 26, 10:02 am, Fuse <[email protected]> wrote:
> Hello
>
> I have been using ruby for some basic scripting but am now starting to
> venture into using Sequel and Sinatra.
>
> I have a couple questions that I hope someone can help me with.  I am
> working with a MSSQL and Oracle database.
>
> First Question:
> I want to query datasets out from MSSQL and insert them into an Oracle
> table.
>
> I tried to do the following with no success:
> DBa=Sequel.connect("oracle://...")
> DBb=Sequel.connect("tinytds://...")
>
> DBa[:table].import([:x, :y], DBb[:table2].select(:a, :b))
>
> Is there a way that I can do this, or is this not supported?

You probably want:

  DBa[:table].import([:x, :y], DBb[:table2].select_map([:a, :b]))

The reason your code doesn't work by default is that when you provide
a dataset as the 2nd argument to import, it uses a single SQL query
with a subselect.  select_map returns an array of arrays, which will
use separate insert statements into the oracle database for each row
in the MSSQL database.

> Second Question:
> I want to create a simple reporting app using Sinatra (and Sequel)
> that connects to the Oracle database.  Is there a best practice around
> using the disconnect method?  Will Sequel automatically disconnect the
> connection or do I need to specify it after every statement?

In general, the only time you ever need to disconnect manually is
before forking in a multi-process program.  Sequel will keep the
database connection open between requests.  Now, if you want to
connect and disconnect on each request, you can probably have a rack
middleware that calls disconnect after the action returns.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to