Re: Loading a list of SQL scripts with relative paths

Поиск
Список
Период
Сортировка
От Leif B. Kristensen
Тема Re: Loading a list of SQL scripts with relative paths
Дата
Msg-id 200505102058.37501.leif@solumslekt.org
обсуждение исходный текст
Ответ на Loading a list of SQL scripts with relative paths  (Michael Glaesemann <grzm@myrealbox.com>)
Ответы Re: Loading a list of SQL scripts with relative paths  (Michael Glaesemann <grzm@myrealbox.com>)
Список pgsql-general
On Tuesday 10 May 2005 17:24, Michael Glaesemann wrote:
> This works well, but I think I'll have to change all of the paths
> when I move the group of scripts to the production server to load
> them. What I'd like to do is be able to use paths relative to the
> file that contains the \i commands. This doesn't seem to work when
> using \i.
>
> I imagine that I'm not alone in wanting to load a bunch of scripts at
> a go, and I'm wondering how others handle this situation. Advice?
> Suggestions? What works for you?

I had a similar problem, which I solved by using environment variables:

> After scrutinizing the psql documentation at
> <http://www.postgresql.org/docs/8.0/static/app-psql.html>, I found
> that this actually works:
>
> leif=> \set importdir `echo $IMPORTDIR`
> leif=> \echo :importdir
> /home/leif/slekta/import/scripts
>
> This doesn't:
>
> leif=> \i :importdir/test.sql
> \i: extra argument "/test.sql" ignored
>
> But this does:
>
> leif=> \cd :importdir
> leif=> \i test.sql
>
> So, the problem is solved, sort of. It may also be prudent to save the
> old pwd and return there when the work is done:
>
> leif=> \set olddir `echo $PWD`
> leif=> \set importdir `echo $IMPORTDIR`
> leif=> \cd :importdir
> leif=> \i test.sql
> leif=> \cd :olddir

Here's the whole thread:
<http://www.mail-archive.com/pgsql-general@postgresql.org/msg60216.html>
--
Leif Biberg Kristensen
http://solumslekt.org/

В списке pgsql-general по дате отправления:

Предыдущее
От: Brendan Jurd
Дата:
Сообщение: Re: Shorthand for foreign key indices
Следующее
От: Tony Caduto
Дата:
Сообщение: Re: Delphi - Developers start develop Access components