Re: [sqlalchemy] alchemy expressionconfusion in insert statement having jsonb field

2016-03-19 Thread Krishnakant



On Wednesday 16 March 2016 02:24 PM, Simon King wrote:

On 16 Mar 2016, at 06:45, Krishnakant  wrote:

Dear all,
I have a challenge which is confusing me.
I have a table called voucher with the following field.
(vid, vdate,Cr) where vid is integer, vdate  is date and Cr is jsonb in
postgresql.
Can some one tell me how do I write an sql expression insert query
involving all the 3 fields?
some thing like con.execute(voucher.insert(),...) I don't know how I do
this.
In the documentation there are 2 fields id and data and it seems id is
auto_increment so inserting with only one field which is only json is
easy, but here I have 3 fields involved in the insert.
So how do I do this?
Happy hacking.
Krishnakant.Krishnakant.

I’m not sure I understand the question. Here are the docs for INSERT 
expressions:

http://docs.sqlalchemy.org/en/rel_1_0/core/tutorial.html#executing-multiple-statements

you should be able to write something like this:

con.execute(voucher.insert(), vid=1, vdate=somedate, Cr=somedict)


Thanks Simon,
It works and I also got another problem worked out.

Happy hacking.
Krishnakant.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] alchemy expressionconfusion in insert statement having jsonb field

2016-03-16 Thread Simon King
> On 16 Mar 2016, at 06:45, Krishnakant  wrote:
> 
> Dear all,
> I have a challenge which is confusing me.
> I have a table called voucher with the following field.
> (vid, vdate,Cr) where vid is integer, vdate  is date and Cr is jsonb in
> postgresql.
> Can some one tell me how do I write an sql expression insert query
> involving all the 3 fields?
> some thing like con.execute(voucher.insert(),...) I don't know how I do
> this.
> In the documentation there are 2 fields id and data and it seems id is
> auto_increment so inserting with only one field which is only json is
> easy, but here I have 3 fields involved in the insert.
> So how do I do this?
> Happy hacking.
> Krishnakant.Krishnakant.

I’m not sure I understand the question. Here are the docs for INSERT 
expressions:

http://docs.sqlalchemy.org/en/rel_1_0/core/tutorial.html#executing-multiple-statements

you should be able to write something like this:

con.execute(voucher.insert(), vid=1, vdate=somedate, Cr=somedict)

Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.