Path for pgsql \i option?

Поиск
Список
Период
Сортировка
Искать

Path for pgsql \i option?

От:
Francisco Reyes <lists@natserv.com>
Дата:
I have a number of files I need to include during my database design and
testing.

Is there a way to specify some form of path for pgsql so when I use "\i"
it would know what directory to try and load the file from?


Re: Path for pgsql \i option?

От:
Jason Tan <jason@rebel.rebel.net.au>
Дата:

You can specify absolute paths.

contacts=# \! pwd
/home/jtan
contacts=# \! ls /home/jtan/Projects/contacts/db
:	    basedata		 builddb.sql   granter.pl  plpgsql.sql
;w	    basedata.sql	 entitydb.sql  log	   tables
RCS	    belongs_to_org.sql	 flech	       logger.sql  testdata.sql
Table1.txt  belongs_to_org2.sql  grant_apache  pids	   testfunc
contacts=# \i /home/jtan/Projects/contacts/db/testdata.sql

The above will work.

You can also speicify relative paths:

contacts=# \!pwd       
contacts=# \! ls ..
:	    basedata		 builddb.sql   granter.pl  plpgsql.sql
;w	    basedata.sql	 entitydb.sql  log	   tables
RCS	    belongs_to_org.sql	 flech	       logger.sql  testdata.sql
Table1.txt  belongs_to_org2.sql  grant_apache  pids	   testfunc
contacts=#       
/home/jtan/Projects/contacts/db/flech
contacts=# \i ../testdata.sql

You can also include lots of \i directives in a file you run with \i.
Eg if have a file called builddb.sq; that contains:

\i schema.sql
\i /home/cotnacts/data/base/data.sql
\i ../testdata.sql

You can then go:

\i builddb.sql

and it will try to run a file in the crrent dir called schema.sql it will run 
that and it will run /home/contacts/data/base/data.sql it will then run
../testdata.sql.

You can find this stuff our really easily by trying it.

Jason

On Tue, 11 Sep 2001, Francisco Reyes wrote:

> I have a number of files I need to include during my database design and
> testing.
> 
> Is there a way to specify some form of path for pgsql so when I use "\i"
> it would know what directory to try and load the file from?
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 

--
------------------------------------------------------------------------------
Jason Tan                                                jason@rebel.net.au
     "Democracy is two wolves and a lamb voting on what to have for lunch. 
                 Liberty is a well-armed lamb contesting the vote."
                               ~Benjamin Franklin, 1759
------------------------------------------------------------------------------

Re: Path for pgsql \i option?

От:
Francisco Reyes <lists@natserv.com>
Дата:
On Tue, 11 Sep 2001, Jason Tan wrote:
> You can specify absolute paths.


That's what I have been using.

> You can also speicify relative paths:

I tried relative paths and didn't seem to work.
In particular I tried something like:
\i inc/myfile.inc

Where "inc" was a subdirectory.
I did not try:
\i ./inc/myfile.inc

will try than when I get back to work.. no electricity on whole area where
I work due to terrorist attack.

> You can also include lots of \i directives in a file you run with \i.
> Eg if have a file called builddb.sq; that contains:

That could be usefull.


FAQ