On Friday, September 26, 2014 4:07:15 AM UTC-7, Bruno Sutic wrote:
>
> Hi, I'm a rails developer learning about postgres. I just discovered 
> 'sequel' and I'm blown away.
>
> I want to make a small demo about the foreign data wrappers in postgres 
> for friends.
> I've searched sequel docs but couldn't find anything related to 'foreign 
> data wrappers'.
>
> Does sequel have support for this? Will this be available in the future 
> maybe?
>
> As indicated above - this is a mostly "for fun" investigation, not related 
> to work or a project.
>
> Here are the rough steps I'd like to do via sequel, preferably not via 
> `DB.run()`:
>
> CREATE DATABASE foobar;
> CREATE EXTENSION file_fdw;
> CREATE SERVER my_server FOREIGN DATA WRAPPER file_fdw;
>

The recommendation for these would be to use DB.run. :) In general, for 
database-specific SQL like this, I think that trying to abstract it doesn't 
add a lot of value.
 

> CREATE FOREIGN TABLE books (
> id VARCHAR(255),
> cat VARCHAR(255),
> name VARCHAR(255),
> price DECIMAL(5, 2),
> inStock BOOLEAN,
> author VARCHAR(255),
> series VARCHAR(255),
> sequence INTEGER,
> genre VARCHAR(255)
> )
> SERVER my_server
> OPTIONS (
> format 'csv', header 'true', filename 'path_to_file.csv', delimiter ',', 
> null ''
> );
>

Since this is very similar to CREATE TABLE, it makes sense to support it 
via add options to DB.create_table, so you could do:

DB.create_table(:foreign=>:my_server, :options=>'{:format=>'csv', 
:header=>'true', :filename=>'path_to_file.csv', :delimiter=>','}) do
  column :id, 'varchar(255)'
  # ...
end

I'll see if I can work on that today.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to