database not accepting data properly

Поиск
Список
Период
Сортировка
От Shaan Repswal
Тема database not accepting data properly
Дата
Msg-id CALa+hEQwjuf_t=2tMfqF_wVA9VbiCC-25ohsttfB0yPtnb0-NA@mail.gmail.com
обсуждение исходный текст
Ответы Re: database not accepting data properly  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: database not accepting data properly  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список psycopg
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).

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
Вложения

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

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: Re: How to use "WHERE NOT EXISTS in INSERT STATEMENT"
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: database not accepting data properly