Re: psycopg2.DataError: invalid input syntax for integer: ""

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: tango ward <tangoward15(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: psycopg2.DataError: invalid input syntax for integer: ""
Date: 2018-05-07 13:35:30
Message-ID: 95a3e004-ee59-947b-9839-4142ac9174f4@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/06/2018 11:05 PM, tango ward wrote:
> Yes, my apologies.
>
> May I also ask if there's a limitation for the number of timestamp with
> timezone fields in a table?
>
> On Mon, May 7, 2018 at 1:37 PM, David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com <mailto:david(dot)g(dot)johnston(at)gmail(dot)com>> wrote:
>
> Please keep replies on-list, don't top-post, and double-check that
> the database table doesn't somehow have an integer column where you
> think its text.
>
>
> On Sunday, May 6, 2018, tango ward <tangoward15(at)gmail(dot)com
> <mailto:tangoward15(at)gmail(dot)com>> wrote:
>
> Yeah, the error doesn't really explain much. I have tried
> putting the string formatter in ' ', still no good.
>
> On Mon, May 7, 2018 at 12:14 PM, David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com <mailto:david(dot)g(dot)johnston(at)gmail(dot)com>>
> wrote:
>
> On Sunday, May 6, 2018, tango ward <tangoward15(at)gmail(dot)com
> <mailto:tangoward15(at)gmail(dot)com>> wrote:
>
> Hi,
>
> There's a mistake in the code, my bad.
>
> I updated the code into
>
> |cur_p.execute(""" INSERT INTO a_recipient (created, mod,
> agreed, address, honor) VALUES (current_timestamp,
> current_timestamp, current_timestamp, %s, %s)""",('', ''))
>
>
>
> |
>
> The code still won't work. The address and honor fields
> are textfields in Django models.py.
>
>
> Not sure but I'm thinking you at least need to add single
> quotes around the %s symbols.  That doesn't really explain
> the integer input error though I'm not familiar with the
> exact features of the execute method in Python.

They do not need to be quoted:

http://initd.org/psycopg/docs/usage.html#passing-parameters-to-sql-queries

>
> David J.
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-05-07 13:40:39 Re: psycopg2.DataError: invalid input syntax for integer: ""
Previous Message David G. Johnston 2018-05-07 13:12:53 Re: psycopg2.DataError: invalid input syntax for integer: ""