Search Postgresql Archives

Loading a list of SQL scripts with relative paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux