Multiple atributes with -P switch to psql

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

Multiple atributes with -P switch to psql

От:
"Harvey, Allan AC" <HarveyA@OneSteel.com>
Дата:
Hi all,

Trying to get psql to produce multiple table attributes in the  tag when psql is used with the -H switch.

eg
TABLEOPTIONS="-P border=5 -P tableattr=width=\"80%\""
psql $DATABASEHOST -U $DATABASEUSER -d $DATABASE -q -P footer -P title=Summary -H $TABLEOPTIONS 

produces
...
... As expected. TABLEOPTIONS="-P border=5 -P tableattr=width=\"80%\" -P tableattr=bgcolor=\"#FFFFFF\"" produces ...
... Seems to hang on to the last. And TABLEOPTIONS="-P border=5 -P tableattr=\"width=\"80%\" bgcolor=\"#FFFFFF\"\"" produces ...
... My quoting of the quotes is wrong but the point is that the quote to encapsulate the white space for the tablattr is placed into the HTML produced. It maybe that you can only pass one table attribute or that I'm missing something. I favour the latter. Calls are from within a bash script. Can anyone set me straight? version ------------------------------------------------------------------------------------- PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 (SuSE Linux) (1 row) Thanks Allan The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient, use, disclosure or copying of this information is prohibited. If you have received this document in error, please advise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses contained in this email or any attachments.

Re: Multiple atributes with -P switch to psql

От:
"Stuart Cooper" <stuart.cooper@gmail.com>
Дата:
Hi Allan,

> TABLEOPTIONS="-P border=5 -P tableattr=width=\"80%\" -P tableattr=bgcolor=\"#FFFFFF\""

> produces
 ...
> 
 ...

> Seems to hang on to the last.

Yes- you've said -P tableattr twice so the second one overrides the first one.

$ psql -H  -P tableattr='width="80%" bgcolor="#FFFFFF"'

works for me. Carefully study my nice simple quoting: single quotes ''
around the whole
tableattr='THING' shebang and non-escaped double quotes "" for width
and bgcolor values.

Cheers,
Stuart.

Re: Multiple atributes with -P switch to psql

От:
"Harvey, Allan AC" <HarveyA@OneSteel.com>
Дата:
Stuart,

Thanks for the reply.

You are dead right, and as expected the problem is not with psql.

> $ psql -H  -P tableattr='width="80%" bgcolor="#FFFFFF"'
> 
> works for me. Carefully study my nice simple quoting: single quotes ''
> around the whole
> tableattr='THING' shebang and non-escaped double quotes "" for width
> and bgcolor values.
> 
> Cheers,
> Stuart.
> 

In my defence I did try that exact quoting, the problem is that it is being run from a script. I have thrown together an example to show the problem.
I have not yet worked to a solution.

If you know what it is I would be very greatful.

Allan


#!/bin/bash
set -x

DATABASEHOST="-h jitsnwm"
DATABASEUSER=galvuser
DATABASE=galvdb

TABLEOPTIONS="-P border=5 -P tableattr='width=\"80%\" bgcolor=\"#AFAFAF\"'"

ED=/usr/local/pgsql/bin

$ED/psql $DATABASEHOST -U $DATABASEUSER -d $DATABASE -q -P footer -P title=Summar
y -H $TABLEOPTIONS < ./z.sh
+ DATABASEHOST=-h jitsnwm
+ DATABASEUSER=galvuser
+ DATABASE=galvdb
+ TABLEOPTIONS=-P border=5 -P tableattr='width="80%" bgcolor="#AFAFAF"'
+ ED=/usr/local/pgsql/bin
+ /usr/local/pgsql/bin/psql -h jitsnwm -U galvuser -d galvdb -q -P footer -P title=Summary -H -P border=5 -P 'tableattr='\''width="80%"' 'bgcolor="#AFAFAF"'\'''
Summary
version
PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 (SuSE Linux)
The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient, use, disclosure or copying of this information is prohibited. If you have received this document in error, please advise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses contained in this email or any attachments.
FAQ