On Monday, June 22, 2015 at 9:49:11 AM UTC-7, Tiger Nassau wrote:
>
> trying to make some REST type calls from sinatra using postgres jsonb.  
> each of our tables is like :   id: primary key,   data: jsonb
>
> db.run ('create table .....')  runs fine and creates table 
>
> res = db.run("select data from signups;")
> post res 
>   ==> runs without error but no output
>

DB.run is designed for running arbitrary SQL, not for returning results (it 
always returns nil).

db.run(insert into signups (data) values ('{"email"=>"[email protected]", 
>   "full_name": "john doe"}') ) 
>   ==>  does not run - the db.run wants quotes but so does the postgres 
> values statement - tried to escape the quotes with \'  but that didn't work 
> either 
>

You would have to get the quoting correct.  I'd use a %q quote:

db.run(%q[insert into signups (data) values ('{"email"=>"[email protected]", 
"full_name": "john doe"}'])
 

>
> db[:posts].insert(:data=>Sequel.pg_jsonb(data))
>   ==>  works fine  but is hard to call from function 
>

That's the expected way to do it.  Is there a reason it is hard to call 
from a function?
 
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