Thread: Path for pgsql \i option?

Path for pgsql \i option?

From
Francisco Reyes
Date:
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?

From
Jason Tan
Date:
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?

From
Francisco Reyes
Date:
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.