Re: SQL equivalint of #incude directive ?

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: SQL equivalint of #incude directive ?
Дата
Msg-id CA+bJJbzuOdifU8Dikyp3kF9jL6abNdY4Kj2Qudv4TEOzyQsF1Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: SQL equivalint of #incude directive ?  (Tony Shelver <tshelver@gmail.com>)
Список pgsql-general
Tony:

On Sun, Sep 1, 2019 at 10:05 AM Tony Shelver <tshelver@gmail.com> wrote:
> I think you will find that most DBAs build their own scripts using tools like Perl or Python, or a commercial
product.

Tools like Perl are great for building text output, it's got a lot of
shortcuts for a lot of things. Not that sure about python. But I think
this are more used by developers wearing dba hats, or for dbas which
double duty as developer / sysadmins. Any dba needs some programming
skills, specially when dealing with dbs with procedure capabilities,
but not that much.

For a pure DBA I would recommend more things like a classic
preprocessor (I've got some success with m4, specially when using
m4sugar with it, and I'm sure there are better ones around there) or
some templating system. For just text CPP can be used, but it knows a
bit about C syntax which can become a nuisance, but for just includes
it can be fine.

> A similar situation exists for HTML, there is no standard pre-processor directive.

IMO the reason is the same. SQL and HTML are not "source code", they
are the final product, the thing you send over an http connection ( in
html case ) or an implementation defined way ( i.e. inside the socket
connections psql makes using libpq ). They are like the window exes,
or the unix elf binaries. In the HTML case there are lots of
templating systems which you use to build the HTML content, in many
cases on the fly, and many of them can be reused easily for SQL.

I think the trick is not treating the SQL as the source, but as an EXE
file. Once you start thinking of it as such lots of things in your
usual toolbox become useful. I routinely do something similar for
configuration files, using just shell scripts full of echo+multiline
constant + source aux files + source some echoing files and, if quotes
are used for something like column names, cat + here docs.

Francisco Olarte.



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

Предыдущее
От: Tony Shelver
Дата:
Сообщение: Re: SQL equivalint of #incude directive ?
Следующее
От: stan
Дата:
Сообщение: pgmodeler ?