tags:

views:

88

answers:

2

How can I save a PostgreSQL table to HTML?

+1  A: 

Here is an example of an XML "forest":

SELECT xmlforest (
  "FirstName" as "FName", "LastName" as "LName",
  ’string’ as "str", "Title", "Region" )
FROM "Demo"."demo"."Employees";

With some data in the employees table, this might result in:

<FName>Nancy</FName>
<LName>Davolio</LName>
<str>string</str>
<Title>Sales Representative</Title>
<Region>WA</Region>
...
<FName>Anne</FName>
<LName>Dodsworth</LName>
<str>string</str>
<Title>Sales Representative</Title>

http://wiki.postgresql.org/wiki/XML_Support

Robert Harvey
He said /HTML/, which is a significantly harder problem.
Matthew Flaschen
+6  A: 

I'll take a stab at assuming what you mean. In psql:

dbname=# \H
dbname=# \d tablename
Gary Chambers
or possibly if you want the data, then \H followed by a select statement. The key point is that the \H command (or the -H or --html command line options) in psql turn on "html output mode".
Stobor