Re: database not accepting data properly

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: database not accepting data properly
Дата
Msg-id 56C9DEBA.3070006@aklaver.com
обсуждение исходный текст
Ответ на database not accepting data properly  (Shaan Repswal <shaun.reapswaal@gmail.com>)
Список 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.klaver@aklaver.com


В списке psycopg по дате отправления:

Предыдущее
От: Shaan Repswal
Дата:
Сообщение: database not accepting data properly
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: database not accepting data properly