Re: Importing SQLite database

From: Steve Atkins <steve(at)blighty(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Importing SQLite database
Date: 2016-12-10 19:47:58
Message-ID: 86F132FB-2DD9-452C-A702-2C1551F4941E@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On Dec 10, 2016, at 11:32 AM, Igor Korot <ikorot01(at)gmail(dot)com> wrote:
>
> Hi, guys,
> I'm working thru my script and I hit a following issue:
>
> In the script I have a following command:
>
> CREATE TABLE playersinleague(id integer, playerid integer, ishitter
> char, age integer, value decimal, currvalue decimal, draft boolean,
> isnew char(1), current_rank integer, original_rank integer, deleted
> integer, teamid integer, notes varchar(125), PRIMARY KEY(id,playerid),
> foreign key(id) references leagues(id), foreign key(playerid)
> references players(playerid),foreign key(teamid) references
> teams(teamid));
>
> Now this command finished successfully, however trying to insert a
> record with following command:
>
> INSERT INTO playersinleague VALUES(1,1,'1',27,42.0,42.0,0,'0',1,1,0,23,NULL);
>
> gives following error:
>
> psql:/Users/igorkorot/draft.schema:10578: ERROR: column "draft" is of
> type boolean but expression is of type integer
>
> Looking at https://www.postgresql.org/docs/9.5/static/datatype-numeric.html,
> I don't see a 'boolean' as supported data type.

Booleans aren't numeric.

https://www.postgresql.org/docs/9.5/static/datatype-boolean.html

Boolean will take a range of formats, including '0' - an untyped literal
"0". But it won't take an integer, which is what an unquoted 0 is.

You'll need to modify your insert statement slightly to use a valid boolean
value for that field ("true" or "false" are idiomatic).

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2016-12-10 19:50:10 Re: Importing SQLite database
Previous Message Pavel Stehule 2016-12-10 19:43:44 Re: Importing SQLite database