Loading a list of SQL scripts with relative paths

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Loading a list of SQL scripts with relative paths
Дата
Msg-id be68ecd71d2689ac5dbfd18541b65eb6@myrealbox.com
обсуждение исходный текст
Ответы Re: Loading a list of SQL scripts with relative paths  (Peter Eisentraut <peter_e@gmx.net>)
Re: Loading a list of SQL scripts with relative paths  ("Leif B. Kristensen" <leif@solumslekt.org>)
Список pgsql-general
Hello,

I often test SQL in separate text files, loading them into the server
using psql -d -f from the command line, wrapping the SQL in a BEGIN;
... ROLLBACK; transaction until I'm sure it does what I want. Often the
SQL script is just a small part of a larger chunk of work I'm doing on
the development server, so I'll have a number of these files that I'll
want to apply to the production server at a single time. I've been
trying to figure out an efficient way to load all of the scripts
together.

One option is to copy all of the scripts into one file, which I have
done on occasion. What I've been doing more recently is making an
additional file that uses \i to call the other files, for example

\i /path/to/script1
\i /path/to/script2
\i /path/to/script3

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?

Michael Glaesemann
grzm myrealbox com


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

Предыдущее
От: "Jimmie H. Apsey"
Дата:
Сообщение: pg_dump fails on 7.4 Postgres
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL