[Tutor] UPDATE, pyhthon+postgre
nitin chandra
nitinchandra1 at gmail.com
Wed Jun 1 13:09:20 EDT 2016
Thank you Stephen, Johnf,
This is what I did and it worked :-
todayTime2 = datetime.datetime.now()
todayTime1 = timezone('Asia/Calcutta').localize(todayTime2)
time_created=%s
WHERE group_code = %s;""", ( .....,...,..., str(todayTime1),....))
Thanks for the Hint, Johnf :)
Nitin
On 1 June 2016 at 18:53, john <johnf at jfcomputer.com> wrote:
> cursor1.execute("""UPDATE employee SET
> name=%s,
> add=%s,
> add1=%s,
> city=%s,
> state_county=%s,
> country=%s,
> basic=%s,
> WHERE group_code = %s""" %
> (name,add,add1,city,state_county,country,basic,grpCode))
>
> It appears that you are not required to provide any time or date since you
> created a default. Of course that assumes you want today and now.
>
> If that assumption is wrong then lookup "datetime". To make life a little
> easier lookup the module "dateutil". You would use either of those modules
> to convert your python input to the correct output for postgres (actually
> for any sql database).
>
> Hint: if the field requires a string you should place quotes around the
> placeholder as in '%s'.
>
> Johnf
>
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list