[SQL] bash & postgres

2009-03-22 Thread Greenhorn
Hi,

I'm trying to pass variables on a bash script embedded with psql commands.

cat header.txt

"to1","from1","subject1"
"to2","from2","subject2"
"to3","from3","subject3"
"to4","from4","subject4"

cat b.sh

#!/bin/bash
two="2"

psql -h localhost -U postgres -d mobile -c "create temp table header (

 field_1   textnot null,
 field_2   textnot null,
 field_3   textnot null

);

\\copy header FROM header.txt CSV

SELECT * FROM header limit "$two"; "


When I execute b.sh

ERROR:  syntax error at or near "\"
LINE 10: \copy header FROM header.txt CSV
 ^

How do I use \c (or any other psql commands beginning with a "\") in a
bash script?

Thanks.

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] pg_restore error - Any Idea?

2009-03-22 Thread DM
Hi All,

I am facing an error on executing the below command

dump name: pg_dump_FcZ0.pnps_200903041201_1.2.1.0_base_testing
databae name: pnqd_test

$pg_restore -U postgres -p 5433 -d pnqd_test
pg_dump_FcZ0.pnps_200903041201_1.2.1.0_base_testing

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3715; 0 0 ACL monitor
postgres
WARNING: errors ignored on restore: 1

I am not able to figure out this issue. Any idea guys.

Thanks
Deepak


Re: [SQL] [GENERAL] pg_restore error - Any Idea?

2009-03-22 Thread Erik Jones


On Mar 22, 2009, at 10:44 PM, DM wrote:


Hi All,

I am facing an error on executing the below command

dump name: pg_dump_FcZ0.pnps_200903041201_1.2.1.0_base_testing
databae name: pnqd_test

$pg_restore -U postgres -p 5433 -d pnqd_test  
pg_dump_FcZ0.pnps_200903041201_1.2.1.0_base_testing


pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3715; 0 0 ACL  
monitor postgres

WARNING: errors ignored on restore: 1

I am not able to figure out this issue. Any idea guys.



TOC -> Table of Contents

A dump made with pg_dump's -Fc will contain a table of contents of all  
of the database objects in the dump file.  Something in that is  
causing an error for pg_restore.  Does the version of pg_restore match  
up with the version of pg_dump that you used to make the dump?


Erik Jones, Database Administrator
Engine Yard
Support, Scalability, Reliability
866.518.9273 x 260
Location: US/Pacific
IRC: mage2k






--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] bash & postgres

2009-03-22 Thread Erik Jones

On Mar 22, 2009, at 9:03 PM, Greenhorn wrote:


Hi,

I'm trying to pass variables on a bash script embedded with psql  
commands.


cat header.txt

"to1","from1","subject1"
"to2","from2","subject2"
"to3","from3","subject3"
"to4","from4","subject4"

cat b.sh

#!/bin/bash
two="2"

psql -h localhost -U postgres -d mobile -c "create temp table header (

field_1   textnot null,
field_2   textnot null,
field_3   textnot null

);

\\copy header FROM header.txt CSV

SELECT * FROM header limit "$two"; "


When I execute b.sh

ERROR:  syntax error at or near "\"
LINE 10: \copy header FROM header.txt CSV
^

How do I use \c (or any other psql commands beginning with a "\") in a
bash script?


For multi-line input to a psql call in a bash (or any decent shell)  
script, I'd use a here document:


#!/bin/bash

#!/bin/bash
two="2"

psql -d pagila <(P.S. Your quotes around $two in your original are not needed, in fact  
they're straight up broken as $two is already inside of a double- 
quoted string).


Erik Jones, Database Administrator
Engine Yard
Support, Scalability, Reliability
866.518.9273 x 260
Location: US/Pacific
IRC: mage2k






--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql