From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Shaan Repswal <shaun(dot)reapswaal(at)gmail(dot)com>, psycopg(at)postgresql(dot)org |
Subject: | Re: database not accepting data properly |
Date: | 2016-02-21 15:58:50 |
Message-ID: | 56C9DEBA.3070006@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 02/21/2016 02:45 AM, Shaan Repswal wrote:
> Hey guys, I hope I used the Mailing List properly. I am trying to upload
> a datetime.timedelta object into a column of type interval... But when I
> query it says datetime.interval(0)
Can you post the actual error message?
What are you querying that gets you datetime.interval[0]?
>
> here are the lines where the error probably is:-
> print(cur.mogrify("""SELECT %s, %s, %s, %s""", (self.start_time.date(),
> self.start_time.time(), datetime.datetime.now() - self.start_time,
> desc_text)))
> cur.execute("""INSERT INTO sessionlogs(sessiondate,
> sessiontime, sessionduration, sessiondesc)
> VALUES(%s, %s, %s, %s);""",
> (self.start_time.date(), self.start_time.time(), datetime.datetime.now()
> - self.start_time, desc_text))
>
> although when I wrote another script to enter a specific code, it was
> working just fine.
>
> datetime.datetime.now() - self.start_time is the time interval which
> seems to be where the error is.
>
> when I did this :-
> cur.execute("""INSERT INTO sessionlogs(sessiondate, sessiontime,
> sessionduration, sessiondesc)
> VALUES (%s, %s, %s, %s)""",
> (datetime.datetime.now().date(), datetime.datetime.now().time(),
> datetime.timedelta(1, 18268), "This is a manual entry"))
>
> It was working quite fine.
>
> I will attach the two scripts
>
> Sorry for the uber messy code. I hope you can read through my whole
> script as it isn't very big. I am using Gtk 3+ here so be warned... :P
>
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2016-02-22 15:41:32 | Re: database not accepting data properly |
Previous Message | Shaan Repswal | 2016-02-21 10:45:34 | database not accepting data properly |