Thread: load sql from the file in postgresql

load sql from the file in postgresql

From
Sukuchha Shrestha
Date:
hello group,

I just started to use postgresql and i want to import data using copy command in a loop.

Here is what i did !

1) following content with name loaddata.sql.
\copy table from 'C:\psql\x.txt';
\copy table from 'C:\psql\y.txt';

2) My loaddata.sql is located in C:\psql\ therefore i tried to call the loaddata.sql in psql like

\i  C:\psql\loaddata.sql


But it says " C:: Permission denied"

What is a problem ? Please guide me ! Is there any better way to call copy commad in a loop with varying filename!

regards
Sukuchha

Re: load sql from the file in postgresql

From
Raghavendra
Date:
\i  C:\psql\loaddata.sql


But it says " C:: Permission denied"


Give the permission to postgres user on 'loaddata.sql' file. Right click and in properties give full access to postgres user.

Best Regards,
Raghavendra
EnterpriseDB Corporation
The Enterprise Postgres Company

 

Re: load sql from the file in postgresql

From
Adrian Klaver
Date:
On Friday, April 29, 2011 4:01:03 am Raghavendra wrote:
> > \i  C:\psql\loaddata.sql
> >
> >
> > But it says " C:: Permission denied"
>
> Give the permission to postgres user on 'loaddata.sql' file. Right click
> and in properties give full access to postgres user.

Just to be clear this means the user you are logged in as when you do the \i
command, which may or may not be the user postgres.  The rule is, COPY runs with
the permissions of the server and \copy with the permissions of the client.

>
> Best Regards,
> Raghavendra


--
Adrian Klaver
adrian.klaver@gmail.com

Re: load sql from the file in postgresql

From
Dennis Grimm
Date:

Try using this, even on a windows system:

 

\i /psql/loaddata.sql

 

psql likes *nix path names


From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Sukuchha Shrestha
Sent: Friday, April 29, 2011 5:40 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] load sql from the file in postgresql

 

hello group,

 

I just started to use postgresql and i want to import data using copy command in a loop.

 

Here is what i did !

 

1) following content with name loaddata.sql.

\copy table from 'C:\psql\x.txt';

\copy table from 'C:\psql\y.txt';

 

2) My loaddata.sql is located in C:\psql\ therefore i tried to call the loaddata.sql in psql like

 

\i  C:\psql\loaddata.sql

 

 

But it says " C:: Permission denied"

 

What is a problem ? Please guide me ! Is there any better way to call copy commad in a loop with varying filename!

 

regards

Sukuchha

 


_______________


Confidentiality Notice: This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to
which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.

________________