Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fFgWv-0003av-Rj for pgsql-general@arkaria.postgresql.org; Mon, 07 May 2018 13:50:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fFgWu-0004PA-Ig for pgsql-general@arkaria.postgresql.org; Mon, 07 May 2018 13:50:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fFgWu-0004OG-A5 for pgsql-general@lists.postgresql.org; Mon, 07 May 2018 13:50:16 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fFgWL-0003Hb-QF for pgsql-general@lists.postgresql.org; Mon, 07 May 2018 13:50:15 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7A5792254B; Mon, 7 May 2018 09:49:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 07 May 2018 09:49:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=VwlX+pw3WW3J2/LF9MwbxSQGwNmiz hri3eSNu6mizqk=; b=NqTqH/YlvfcPbvli0k6MDHhXSjNKrIlY90ODujnWJHfrU +mTV9uge8GHyTkAq0djJt4fMgFtQEFvMhatjOlfA9r/QHj5xhMJFn8wc4qSM9ive DR232izYvK4r7mRK8xmDbuUZ2KrM6F/AKkI88KSVaN9jHZuuC+EtqXPdtdWUY3+j P8pnrIB76fE3oW7gtx7A8nmWFLO81MyOAnRArmHTXQUoLDmlfcsX2Q7XS+G/ULnD hrnIn6IpLBI3U/5WrZ/8gaTtYa4eN/gmH+PhxQlPQYo4lbirPkrEtgQcjMtFewfI f4ck9No15EudhLivBhl1L2LN3v7yiaHzJEiCGbn0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=VwlX+p w3WW3J2/LF9MwbxSQGwNmizhri3eSNu6mizqk=; b=QASGmFXt6bpPwIjDELDlNe +0vuTVXWC52/kvFRd6WSJRqYWYJlzEjphrOdV/jnYhr4wy8tdEleJkhXRh6jg9vF vSH7rRdrRpzLbjo+WUbnn5CpXYnUT/rWJdJz8lIsqhKyEqLigZ3xiFBbB4LtcEEs UWxFeBRdJFZituC/BocQWj53Bc/7X5ZOJNthsaAp4GRMwIP+mYwluuEDcGFr8N/i qnf83W9oNbJRaGHNNA0ZCbUwtCNpAbJzC34kjyb2kSsd6eBW2+9MdPPc576CU+JO ZweC9IVpgfknMWS9thZbsCT8PkHfGnsOHtF0RIWlJF9zOVNxDSlsiqaO5gPprzuQ == X-ME-Sender: Received: from [192.168.1.2] (unknown [71.212.135.74]) by mail.messagingengine.com (Postfix) with ESMTPA id E1D7D102DA; Mon, 7 May 2018 09:49:38 -0400 (EDT) Subject: Re: psycopg2.DataError: invalid input syntax for integer: "" To: tango ward , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: Date: Mon, 7 May 2018 06:49:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/07/2018 12:28 AM, tango ward wrote: > I think I've found the culprit of the problem. > > I have a field which is varchar from the source DB while on the > destination DB its integer. > > Reading the documentation: > http://www.postgresqltutorial.com/postgresql-cast/ but it gives me error > `psycopg2.DataError: invalid input syntax for integer: ""` Would need to see your code to be sure, but I am gong to guess you are trying to CAST the string to integer in the SQL e.g CAST(some_str_value AS INTEGER) or some_str_value::integer. The error you are getting is : test=# select CAST('' AS INTEGER); ERROR: invalid input syntax for integer: "" LINE 1: select CAST('' AS INTEGER); ^ test=# select ''::integer; ERROR: invalid input syntax for integer: "" LINE 1: select ''::integer; Two options: 1) You will need the catch the '' on the Python side before they get to the database and turn them into None(if Nulls allowed in column) or 0 otherwise. 2) If possible convert the integer column on the destination db to a varchar one. Though I would do some investigation before doing this as this may very well mess up other code. > > On Mon, May 7, 2018 at 2:39 PM, David G. Johnston > > wrote: > > On Sunday, May 6, 2018, 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? > > > Not one that is likely to matter in practice.  There's a page > discussing limitations on the website/docs somewhere if you wish to > find out more. > > David J. > > -- Adrian Klaver adrian.klaver@aklaver.com