3
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
4
<link rel="stylesheet" type="text/css" href="../../../docs/en_US/pgadmin3.css" />
5
<title>pgScript Readme</title>
9
_ __ __ _/ __| __ _ _(_)_ __| |_
10
| '_ \/ _` \__ \/ _| '_| | '_ \ _|
11
| .__/\__, |___/\__|_| |_| .__/\__|
14
<p><b>Table of Contents</b></p>
16
<dt><a href="#overview">Overview / introduction</a></dt>
17
<dt><a href="#install">pgScript install</a></dt>
20
<dt><a href="#requirements">Requirements</a></dt>
21
<dt><a href="#basic">Basic install</a></dt>
24
<dt><a href="#usage">Usage</a></dt>
27
<dt><a href="#usage1">Synopsis</a></dt>
28
<dt><a href="#usage2">Options</a></dt>
29
<dt><a href="#usage3">Example</a></dt>
32
<dt><a href="#reference">pgScript scripting language reference</a></dt>
34
<h2><a id="overview"></a>Overview / introduction</h2>
35
<p>pgScript enhances PostgreSQL SQL commands with these additional features:</p>
37
<li>Control-of-flow language</li>
38
<li>Local variables</li>
39
<li>Random data generators</li>
42
<pre class="screen"> SET @A = INTEGER(0, 10); -- Random integer generator into @A
43
IF (SELECT COUNT(*) FROM table) -- Then table exists
45
SET @B = SELECT * FROM table; -- Stores result of the query in @B
46
INSERT INTO table VALUES (@A); -- Inserts a random integer
47
PRINT @B; -- Prints result of the previous query
49
ELSE -- Else table does not exist
51
CREATE TABLE table ( ... ); -- Regular PostgreSQL command
53
<p>pgScript is built along with pgAdmin and can be accessed through the pgAdmin Query Tool. It can also be built as a command-line program. This document explains how to build and use the <u>command-line interface</u>.</p>
54
<p>The command-line interface is in <code>xtra/pgscript</code> (this directory) while main pgScript source code is in <code>pgadmin/pgscript</code>. </p>
55
<h2><a id="install"></a>pgScript install</h2>
56
<h3><a id="requirements"></a>Requirements</h3>
57
<p>Linux or MinGW environment (should work on MacOS)</p>
58
<p><code>g++.exe</code> (GCC) <code>>=</code> 3.4.x</p>
59
<p>wxWidgets <code>>=</code> 2.8.7</p>
60
<p>PostgreSQL (libpq) <code>>=</code> 8.0</p>
61
<h3><a id="basic"></a>Basic install</h3>
62
<p>Go to the root directory of pgAdmin and enter the following
64
<pre class="screen">./configure</pre>
65
<p>Go to the <code>xtra/pgscript</code> directory and enter the following
70
<p>You can possibly install pgScript binary:</p>
71
<pre class="screen">make install</pre>
72
<h2><a id="usage"></a>Usage</h2>
73
<h3><a id="usage1"></a>Synopsis</h3>
74
<p><code class="command">pgScript</code> <code>-h </code><em><code>host</code></em> [<code>-p </code><em><code>port</code></em>] <code>-d </code><em><code>database</code></em> <code>-U </code><em><code>username</code></em> [<code>-W </code><em><code>password</code></em>] [<code>-e </code><em><code>encoding</code></em>] <em><code>inputfile</code></em></p>
75
<p>The output is UTF8-encoded. </p>
76
<h3><a id="usage2"></a>Options</h3>
78
<dt>-h <em><code>host</code></em></dt>
80
<p>Database server host to connect to e.g <code>127.0.0.1</code></p>
82
<dt>-p <em><code>port</code></em></dt>
84
<p>Database server port number (default: <code>5432</code>)</p>
86
<dt>-d <em><code>database</code></em></dt>
88
<p>Database to connect to</p>
90
<dt>-U <em><code>username</code></em></dt>
92
<p>Username to use for connecting to the database server</p>
94
<dt>-W <em><code>password</code></em></dt>
96
<p>Password to use for connecting to the database server
97
(default: <code>nothing</code>)</p>
99
<dt>-e <em><code>encoding</code></em></dt>
101
<p>Encoding of <code>file</code> e.g <code>utf-8</code>, <code>iso-8859-1</code> (default: <code>system
104
<dt><em><code>pgScript input
105
file</code></em></dt>
107
<p>Path to the file to parse with pgScript (.pgs file)</p>
110
<h3><a id="usage3"></a>Example</h3>
111
<p><strong class="command">pgScript </strong><code>-h 127.0.0.1 -U postgres -W
112
postgres -d testbase -e "utf-8" script.pgs</code></p>
113
<p>This connects to the database <code>127.0.0.1:5432/testbase</code> with the credentials <code>postgres</code>/<code>postgres</code> and parses the UTF-8 encoded file <code>script.pgs</code>. The output is written on screen and is UTF-8 encoded.</p>
114
<h2><a id="reference"></a>pgScript scripting language reference</h2>
115
<p>Refer to pgScript help page in pgAdmin: <a href="../../../docs/en_US/pgscript.html" target="_blank">pgscript.html</a>. </p>