Обсуждение: how to get desired html format output?

Поиск
Список
Период
Сортировка

how to get desired html format output?

От
Anne Wainwright
Дата:
Hello,

new here. i like the 'novice' list title, that about describes me.
part-time hacker, casual coder, would also be good descriptions.

have a one-table database holding descriptive records of catalogued
books.

normally I would output data in a delimited format and use a perl script
to do all the formatting to turn the  data into a full html table. I
have done this very successfully from my old database _but_ this would
export individual <field names> as field delimiters which made it easier
to write the script than, as with postgresql, where we have a uniformly
delimited output.

as a general road map. Is it possible to create output with all the
necessary html code for a table (font attributes and the like) direct
from postgresql (using a psql command)? One command and bingo, one table
ready to drop into my waiting html page?

would this normally be done perhaps with a file that could be called by
psql. This file with all the psql query commands/options and the html
formatting code within?

or should I rather create a new perl script to do the dirty?

if the former, can you please point me to some understandable 'howto' or
other documentation.

bestest & thanks for help

Anne

Re: how to get desired html format output?

От
Jayadevan M
Дата:
Hello,

> would this normally be done perhaps with a file that could be called by
> psql. This file with all the psql query commands/options and the html
> formatting code within?

1) Turn on the HTML output option -
newgendb=# \H
Output format is html.

2) Direct the output to a file

newgendb=# \o myfile.html

3) Execute the select

4) Turn off output
newgendb=# \o

Regards,
Jayadevan





DISCLAIMER:


"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."





Re: how to get desired html format output?

От
Anne Wainwright
Дата:
On Thu, Aug 09, 2012 at 02:57:16PM +0530, Jayadevan M wrote:
> Hello,
>
> > would this normally be done perhaps with a file that could be called by
> > psql. This file with all the psql query commands/options and the html
> > formatting code within?
>
> 1) Turn on the HTML output option -
> newgendb=# \H
> Output format is html.
>
> 2) Direct the output to a file
>
> newgendb=# \o myfile.html
>
> 3) Execute the select
>
> 4) Turn off output
> newgendb=# \o
>
> Regards,
> Jayadevan
>
I know that this will make a table output but it isn't going to do
all the fancy formatting that I need like

<b>author</b> ... <i>condition</i> ... <fontt align=right>price</font>

so my question perhaps needs to be rephrased as 'how do I get specific
html text formatting commands in the html output?'

back to perl maybe? not an issue but being able to do something from
within postgresql would save that extra step.

Anne
>
>
>
>
> DISCLAIMER:
>
> "The information in this e-mail and any attachment is intended only for
> the person to whom it is addressed and may contain confidential and/or
> privileged material. If you have received this e-mail in error, kindly
> contact the sender and destroy all copies of the original communication.
> IBS makes no warranty, express or implied, nor guarantees the accuracy,
> adequacy or completeness of the information contained in this email or any
> attachment and is not liable for any errors, defects, omissions, viruses
> or for resultant loss or damage, if any, direct or indirect."
>
>
>
>

Re: how to get desired html format output?

От
Andrej
Дата:
On 9 August 2012 21:47, Anne Wainwright <anotheranne@fables.co.za> wrote:

> I know that this will make a table output but it isn't going to do
> all the fancy formatting that I need like

> back to perl maybe?

Definitely back to perl, (awk, python, your other weapon of choice.


>  not an issue but being able to do something from
> within postgresql would save that extra step.

Yah, and if it made me breakfast Postgres would be even better! ;}


> Anne

Cheers,
Andrej

Re: how to get desired html format output?

От
Michael Wood
Дата:
Hi

On 9 August 2012 11:47, Anne Wainwright <anotheranne@fables.co.za> wrote:
> On Thu, Aug 09, 2012 at 02:57:16PM +0530, Jayadevan M wrote:
>> Hello,
>>
>> > would this normally be done perhaps with a file that could be called by
>> > psql. This file with all the psql query commands/options and the html
>> > formatting code within?
>>
>> 1) Turn on the HTML output option -
>> newgendb=# \H
>> Output format is html.
>>
>> 2) Direct the output to a file
>>
>> newgendb=# \o myfile.html
>>
>> 3) Execute the select
>>
>> 4) Turn off output
>> newgendb=# \o
>>
>> Regards,
>> Jayadevan
>>
> I know that this will make a table output but it isn't going to do
> all the fancy formatting that I need like
>
> <b>author</b> ... <i>condition</i> ... <fontt align=right>price</font>
>
> so my question perhaps needs to be rephrased as 'how do I get specific
> html text formatting commands in the html output?'
>
> back to perl maybe? not an issue but being able to do something from
> within postgresql would save that extra step.

One other option to investigate would be to use CSS to set the fonts,
text alignment, etc.

I haven't checked the generated HTML to see how feasible this is, though.

--
Michael Wood <esiotrot@gmail.com>