Script to connect to PostgreSQL database


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to connect to PostgreSQL database
# 1  
Old 04-12-2007
Script to connect to PostgreSQL database

Hi All,

Has anyone of you connected to a remote PostgreSQL database through a shell/perl script. Can you please let me know the steps involed?

Thanks.

Rahul.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Setting up postgreSql database

Hi I have a small bash script which I want to run on an Amazon EC2 Ubuntu instance for setting up a postgreSQL database: #!/bin/bash USERNAME='postgres' start=$SECONDS TMP_DIR=/local/test/4g4d PORT=23456 rm -rf $TMP_DIR/db mkdir -p $TMP_DIR/ echo "creating database..."... (3 Replies)
Discussion started by: Helveticus
3 Replies

2. High Performance Computing

Postgresql Database Corrupt

I am managing a linux cluster which has been build on Platform Cluster Manager PCM 1.2.1) from IBM Platform Computing. Unfortunately somebody deteled data files of postgresql from /var/lib directory. I somehow managed to start the postmaster service again, but all the administrative commands of... (2 Replies)
Discussion started by: ahsanpmd
2 Replies

3. Shell Programming and Scripting

How to connect to Oracle database using shell script?

Hi All, I am newbie to unix shell scripting. I want to connect to oracle database using shell script. I know how to connect DB using user name and password but my question is if my password is having '@' sign then how to connect. I have tried like below, cnt=`sqlplus -s /nolog << EOFSQL ... (3 Replies)
Discussion started by: pmotewar
3 Replies

4. Shell Programming and Scripting

Shell Script to connect to the oracle database

Hi Unix Gurus, I have a requirement to write a script, Oracle DB gets referesh every 6hrs, hence we need write a script to connect to the database , if it connects it should generate a file to proceed the next job application or when an error when connectiong to DB it should not generate any... (8 Replies)
Discussion started by: bshivali
8 Replies

5. Shell Programming and Scripting

Korn Script to connect and query oracle database

I've been sent the following script to finish. It's supposed to connect to an oracle database, query it, and send an email if the query result value is one or more. Currently it isn't connecting properly, just giving the following error: ERROR: ORA-01017: invalid username/password; logon denied... (2 Replies)
Discussion started by: jackmorgan2007
2 Replies

6. Shell Programming and Scripting

Perl script to connect to database using JDBC driver?

How to connect to SQL Server database from perl script using JDBC driver? ---------- Post updated at 05:33 PM ---------- Previous update was at 05:07 PM ---------- i have sqljdbc.jar file. by setting the class path how can i connect to the database using perl script? (2 Replies)
Discussion started by: laknar
2 Replies

7. Shell Programming and Scripting

how will i connect postgres database from unix shell script

I have got the solution so just closing this issue. (3 Replies)
Discussion started by: jambesh
3 Replies

8. Shell Programming and Scripting

How to connect to database db2 through Unix Shell Script

I am trying to connect to database db2 through shell script. The process I am trying is > db2 It gives me error Access Denied. While checking for access I have the rights. Is there ant other way round..? Please help. (3 Replies)
Discussion started by: ankitgupta
3 Replies

9. Shell Programming and Scripting

Script to connect to As400 database

Hi, could you please help me out what are the command line commands to connect to as400. Thanks, (0 Replies)
Discussion started by: mgirinath
0 Replies

10. Shell Programming and Scripting

Connect to sybase database using Korn shell script

Hi, Can anyone please give me a script or let me know how to connect to a sybase database and execute a query using Korn shell scripts.Am new to Unix but i need to do this ASAP. Please help. Thanks, Gops (7 Replies)
Discussion started by: bhgopi
7 Replies
Login or Register to Ask a Question
VACUUMDB(1)						  PostgreSQL Client Applications					       VACUUMDB(1)

NAME
vacuumdb - garbage-collect and analyze a PostgreSQL database SYNOPSIS
vacuumdb [ connection-options... ] [ --full | -f ] [ --verbose | -v ] [ --analyze | -z ] [ --table | -t 'table [ ( column [,...] ) ]' ] [ dbname ] vacuumdb [ connection-options... ] [ --all | -a ] [ --full | -f ] [ --verbose | -v ] [ --analyze | -z ] DESCRIPTION
vacuumdb is a utility for cleaning a PostgreSQL database. vacuumdb will also generate internal statistics used by the PostgreSQL query optimizer. vacuumdb is a shell script wrapper around the backend command VACUUM [vacuum(7)] via the PostgreSQL interactive terminal psql(1). There is no effective difference between vacuuming databases via this or other methods. psql must be found by the script and a database server must be running at the targeted host. Also, any default settings and environment variables available to psql and the libpq front-end library do apply. vacuumdb might need to connect several times to the PostgreSQL server, asking for a password each time. It is convenient to have a $HOME/.pgpass file in such cases. OPTIONS
vacuumdb accepts the following command-line arguments: [-d] dbname [--dbname] dbname Specifies the name of the database to be cleaned or analyzed. If this is not specified and -a (or --all) is not used, the database name is read from the environment variable PGDATABASE. If that is not set, the user name specified for the connection is used. -a --all Vacuum all databases. -e --echo Echo the commands that vacuumdb generates and sends to the server. -f --full Perform ``full'' vacuuming. -q --quiet Do not display a response. -t table [ (column [,...]) ] --table table [ (column [,...]) ] Clean or analyze table only. Column names may be specified only in conjunction with the --analyze option. Tip: If you specify columns to vacuum, you probably have to escape the parentheses from the shell. -v --verbose Print detailed information during processing. -z --analyze Calculate statistics for use by the optimizer. vacuumdb also accepts the following command-line arguments for connection parameters: -h host --host host Specifies the host name of the machine on which the server is running. If host begins with a slash, it is used as the directory for the Unix domain socket. -p port --port port Specifies the Internet TCP/IP port or local Unix domain socket file extension on which the server is listening for connections. -U username --username username User name to connect as -W --password Force password prompt. DIAGNOSTICS
VACUUM Everything went well. vacuumdb: Vacuum failed. Something went wrong. vacuumdb is only a wrapper script. See VACUUM [vacuum(7)] and psql(1) for a detailed discussion of error mes- sages and potential problems. ENVIRONMENT
PGDATABASE PGHOST PGPORT PGUSER Default connection parameters. EXAMPLES
To clean the database test: $ vacuumdb test To clean and analyze for the optimizer a database named bigdb: $ vacuumdb --analyze bigdb To clean a single table foo in a database named xyzzy, and analyze a single column bar of the table for the optimizer: $ vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy SEE ALSO
VACUUM [vacuum(7)] Application 2002-11-22 VACUUMDB(1)