[Home] [Download] [Install] [Usage] [Example] [FAQ]

p g b a s h

Pgbash is a BASH shell which includes the functionality of accessing the database for PostgreSQL. It is possible to execute SQL by making a shell script in the batch processing, and execute SQL directly in the interactive environment. And, Pgbash has the convenient functionality for making the simple Web application.

[Japanese] [English]


The newest version of Pgbash is pgbash-7.3 .

Outline of Pgbash
  • Database Interface
    Pgbash has "Direct/Embedded SQL" interface for PostgreSQL. Here, "direct SQL" means the functionality which execute immediately and outputs the results to standard output. And, "Embedded SQL" means the functionality which sets the retrieval result into the shell variables which are processed by using shell script language. Pgbash can use SELECT_INTO or FETCH_INTO statement as "Embedded SQL" interfaces.

  • Processing method of SQL
    Pgbash deals with a SQL statement as a shell command. In short, if 'SQL;' is inputted, 'exec_sql "SQL"' is executed. Therefore, Pgbash can execute a SQL with pipeline, redirection and background_job options.

  • Login shell or Sub shell
    It is possible to start Pgbash as a LOGIN_shell or a SUB_shell. Here, a SUB shell is a child shell started from a parent shell. If you want to start Pgbash as a SUB shell, you type only e.g. '/usr/local/bin/pgbash' after log-in.

    If you start Pgbash as a LOGIN_shell, the logout may be done when there are some database troubles. Considering such fact, it would generally be better that Pgbash is used as a SUB shell.

  • Shell script and Web application
    You can make a shell script with SQL and the control statements such as IF/WHILE and the shell variables using Pgbash. Pgbash has the functionality of inputting data from GET/POST method and ouputting data to HTML table, in order to use a shell script as a Web application.

    The load of the server is higher on the CGI program using Pgbash than on the PHP which is a built-in module of the web server software. So, Pgbash is suited for a Web application of a few access, or a prototype system before making a real Web application.

  • Operation environment
    Pgbash needs the libpq library of PostgreSQL. So, you must describe the path of libpq library in the parent shell. And, Pgbash needs Pgbashrc when Pgbash starts in the interactive environment.

    (What is Pgbashrc)
    Pgbashrc is the shell startup file which sets the various commands for displaying the database information. Pgbash can either use a original Pgbashrc file or modified Pgbashrc file.


Featurs of Pgbash
  • Interactive environment.
    1. Pgbash has a database accessing function equivalent to psql.
    2. Pgbash can set up a user's original interactive environment using pgbashrc.
    3. Pgbash can offer flexible interactive environment, such as alias, function, and history.
    4. Pgbash can execute the SQL statement with pipeline, redirection and background_job options.

  • Extension of SQL.
    1. Pgbash can connect to some databases by using CONNECT, DISCONNECT and SET CONNECTION.
    2. Pgbash has the functionality which sets the retrieval result into the shell variable by using SELECT_INTO/FETCH_INTO statements.
    3. Pgbash implements the original COPY function which not only a postres super user but a general user can copy.
    4. Pgbash keeps the error code after SQL execution, the number of tuples as a result of SELECT, the number of colums and the number of records, to a shell variable. Therefore, it is possible to know the condition after the SQL execution.

  • Web application.
    1. Pgbash has the functionality of changing HTML output mode, reading data from GET/POST method and reading values from HTTP_COOKIE.
    2. Pgbash can print the retrieval results as HTML table format. And, Pgbash can change TABLE tag, HEADER tag, TR tag, TH tag, TD tag.


History
  • 1999.07.01 : An interface was discussed at pgsql-jp ML.
  • 1999.07.15 : KUBO Takehiro opens pqbash to the public by pgsql-jp ML.
  • 1999.07.30 : The examination of Pgbash was started.
  • 1999.08.31 : pgbash-1.0-beta released.
  • 1999.09.06 : pgbash-1.0b2 released.
  • 1999.10.01 : pgbash-1.1.1 released.
  • 1999.10.30 : pgbash-1.2.1 released.
  • 1999.10.31 : pgbash-1.2.2 released. (pgbash-1.2.1 bug fix)
  • 1999.11.22 : pgbash-1.2.3 released.
  • 1999.12.25 : pgbash-2.0 released. (bash-2.03 main body was patched)
  • 2000.01.07 : pgbash-2.0.1 released. (Add Multibyte function, Stop System mesages)
  • 2000.05.16 : pgbash-2.1(bash-2.03) released (for PostgreSQL-6.5/7.0)
  • 2001.05.01 : pgbash-2.2(bash-2.03/2.04/2.05) was released (for PostgreSQL-6.5/7.0/7.1)
  • 2001.12.15 : pgbash-2.4 released. (for PostgreSQL-7.0/7.1/7.2)
  • 2002.02.10 : pgbash-2.4a released. (for bash-2.05a)
  • 2002.05.10 : pgbash-2.4a.1 released.
  • 2002.07.22 : pgbash-2.4a.2 released.
  • 2003.02.11 : pgbash-7.3 released. (for PostgreSQL-7.3 and bash-2.05a)

Link pages


SAKAIDA Masaaki<sakaida@psn.co.jp>
Last Modified at 2003/02/10
# Sorry, I am not good at English.