Skip site navigation (1) Skip section navigation (2)

Re: Reading a file on Windows with psql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Lynn <mr(dot)john(dot)lynn(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Reading a file on Windows with psql
Date: 2009-11-09 15:29:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
John Lynn <mr(dot)john(dot)lynn(at)gmail(dot)com> writes:
> On Windows (Windows Server 2008), I create a file using a tool (Data
> Generator for PostgreSQL), and then try to execute the script using:

> psql --file="C:\PDS\TestData\populate_companies.sql" --dbname=tst --username=tst

> I get an error, pointing to the first character in the file. So I open
> the file using pgAdmin and I see only an "I" (the first character of
> the first command in the file, which is an INSERT) in the file.

> If I load the file into a Windows editor, I see that it's a "unicode"
> file. If I re-save it as a "DOS" file, then psql is able to read it.

> Is there a way to convince psql to read a file in "unicode" format?

Most likely there is a "byte order mark" in the file (a thing that is
both useless and counter to standards in UTF-8 data, but try telling
Microsloth that :-().  There's been some talk of teaching psql to ignore
BOMs but nothing's been done about it.  Saving in the plain text format
is your best bet for now.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Jasen BettsDate: 2009-11-10 10:16:16
Subject: Re: Table design for basic user management
Previous:From: John LynnDate: 2009-11-09 15:23:54
Subject: Reading a file on Windows with psql

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group