Extension:AccessPostgres

What can this extension do?
With this extension you can connect to a Postgres database and retrieve data with select directly into an article or write data into the database with insert and update respectively. You may also delete data from the database.

Usage
The following extension functions are available.

Hint: All functions that perform a select use the user registered as $egOwlApUser. For insert and update the wiki user is used.

#apGetValue
Retrieves one single column from a table under specification of a search key. If the result consists of more than one value, the values are connected comma separated. The result is given as wikitext.

Parameters:
 * table: name of the table you want to receive data from
 * column: name of the column containing the result
 * key: name of the column containing the search key
 * key value: value to search for

#apGetMValues
Retrieves any number of columns from a table under specification of a search key. The result is put into an array and returned as wikitext.

Parameters:
 * table: name of the table you want to receive data from
 * key: name of the column containing the search key
 * key value: value to search for
 * column1...columnn: names of the columns you want to retrieve

#apGetTable
Retrieves any number of columns and all rows from a table. The result is given as HTML table rows.

Parameters:
 * table: name of the table you want to receive data from
 * column1...columnn: names of the columns you want to retrieve

#apGetLine
Retrieves any number of columns from a table under specification of a search key. The result is given as HTML table row.

Parameters:
 * table: name of the table you want to receive data from
 * key: name of the column containing the search key
 * key value: value to search for
 * column1...columnn: names of the columns you want to retrieve

#apCreateEntry
Inserts a new record with any number of columns and a key column into a table. If there exists already a record with the given key value an update is performed instead.

Parameters:
 * table: name of the table you want to insert data into
 * key: name of the column containing the search key
 * key value: value for the key
 * column1...columnn: names of the columns you want to insert data into
 * value1..‹valuen: values you want to insert into the columns

#apUpdateMValues
Updates any number of columns under specification of a search key.

Parameters:
 * table: name of the table you want to update
 * key: name of the column containing the search key
 * key value: value to search for
 * column1...columnn: names of the columns you want to update
 * value1..‹valuen: new values for the columns

#apUpdatePValue
Updates a column under specification of two search keys.

Parameters:
 * table: name of the table you want to update
 * key1: name of the column containing the first search key
 * key value1: first value to search for
 * key2: name of the column containing the second search key
 * key value2: second value to search for
 * column: name of the column you want to update
 * value: new value for the column

#apAddValue
Inserts a new record with two columns (index and value) into a table.

Parameters:
 * table: name of the table you want to insert data into
 * key: name of the column containing the search key
 * key value: value for the key
 * column: name of the column you want to insert data into
 * value: value you want to insert into the column

#apDeletePEntry
Deletes a record from a table under specification of a key value and another search key.

Parameters:
 * table: name of the table you want to delete data from
 * key1: name of the column containing the first search key
 * key value1: first value to search for
 * key2: name of the column containing the second search key
 * key value2: second value to search for

Download instructions
Download the code and unzip it into. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
To install this extension, add the following to LocalSettings.php:

Configuration parameters
Insert the appropriate values for $egOwlApHost, $egOwlApDBName, $egOwlApUser, $egOwlApPassword and $egOwlApSearchPath in file
 * $egOwlApHost: name of the host on which Postgres is running
 * $egOwlApDBName: name of the postgres database to connect to
 * $egOwlApUser: user for select queries
 * $egOwlApPassword: password of $egOwlApUser
 * $egOwlApSearchPath: search path for the database