Stathis Andronikos
Stathis Andronikos

Reputation: 1259

Postgres display a query result into html format

Is there any way to run a query and the resulted output to become into an html format. The query may be into a store procedure, for convenience. As an example usage, I think something like that:

select * from my_stored_proc(arg1, arg2) -> [html formated] result set

or any other way.

Upvotes: 0

Views: 8455

Answers (2)

Aashutosh Rathi
Aashutosh Rathi

Reputation: 785

I found this accidentally, I was using psql -H <connectionString> and was not sure why I was getting HTML outputs.

I found it later -H was flag for getting all HTML responses from psql.

Upvotes: 3

Vao Tsun
Vao Tsun

Reputation: 51436

I doudbt you gonna use psql output to render the page, so probably -H is not an option. and there is no other "native" html conversion in Postgres afaik. I'd rather use js parser to consume xml or json, returned by Postgres instead... (I believe most API calls return either json or xml, so parsing should be very common)

Also, look for similar questions, eg Generate HTML from PostgreSQL function

Upvotes: 2

Related Questions