Extension:AccessPostgres

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
AccessPostgres

Release status:Extension status stable

ImplementationTemplate:Extension#type Database, Parser function
DescriptionTemplate:Extension#description Connects to a PostgresGL database and retrieves data with select directly into an article or to write data into the database with insert and update respectively.
Author(s)Template:Extension#username Martina Mostert (MarMostalk)
Latest versionTemplate:Extension#version 1.3 (1 September 2011(2011-09-01))
MediaWikiTemplate:Extension#mediawiki 1.9+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GPL
Download from external source
ParametersTemplate:Extension#parameters
  • $egOwlApHost
  • $egOwlApDBName
  • $egOwlApUser
  • $egOwlApPassword
  • $egOwlApPasswordGet
  • $egOwlApSearchPath
Hooks usedTemplate:Extension#hook
ArticleSaveCompleteManual:Hooks/ArticleSaveComplete
EditPage::attemptSaveManual:Hooks/EditPage::attemptSave

Translate the AccessPostgres extension if it is available at translatewiki.net

Check usage and version matrix.

The AccessPostgres extension allows to connect to a PostgresQL 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[edit]

The following extension functions are available.

Hint: All functions that perform a select use the user registered as $egOwlApUser using the password in $egOwlApPasswordGet (see #Configuration parameters). For insert and update the wiki user is used (password $egOwlApPassword).

#apGetValue[edit]

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.

     {{#apGetValue:‹table›|‹column›|‹key›|‹key value›}}

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[edit]

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.

     {{#apGetMValues:‹table›|‹key›|‹key value›|‹column1›|...|‹columnn›}}

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[edit]

Retrieves any number of columns and all rows from a table. [1].

     {{#apGetTable:‹table›|‹column1›|...|‹columnn›}}

Parameters:

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

#apGetLine[edit]

Retrieves any number of columns from a table under specification of a search key. [1].

     {{#apGetLine:‹table›|‹key›|‹key value›|‹column1›|...|‹columnn›}}

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[edit]

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.

     {{#apCreateEntry:‹table›|‹key›|‹key value›|‹column1›|‹value1›|...|‹columnn›|‹valuen›}}

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[edit]

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

     {{#apUpdateMValues:‹table›|‹key›|‹key value›|‹column1›|‹value1›|...| ‹columnn›|‹valuen›}}

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[edit]

Updates a column under specification of two search keys.

     {{#apUpdatePValue:‹table›|‹key1›|‹key value1›|‹key2›|‹key value2›|‹column›|‹value›}}

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[edit]

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

     {{#apAddValue:‹table›|‹key›|‹key value›|‹column›|‹value›}}

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[edit]

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

     {{#apDeletePEntry:‹table›|‹key1›|‹key value1›|‹key2›|‹key value2›}} 

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

Note Note:

  1. 1.0 1.1 The result is given as HTML table rows Cite error: Invalid <ref> tag; name "tab" defined multiple times with different content

i.e. you receive <tr><td>''data''</td><td>''data''</td>...</tr>. The rest of the table has to be put "around" the function call, e.g.

<table>
<th>Heading1</th>
<th>Heading2</th>
<th>Heading3</th>
{{#apGetLine:tablename|...}}
</table>

Installation[edit]

  • Download and place the file(s) in a directory called AccessPostgres in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/AccessPostgres/AccessPostgres.php";
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration[edit]

Insert the appropriate values for $egOwlApHost, $egOwlApDBName, $egOwlApUser, $egOwlApPassword and $egOwlApSearchPath in file $IP/extensions/AccessPostgres/AccessPostgres.phpy

* $egOwlApHost: name of the host on which Postgres is running - if left empty, a unix socket is used (localhost)
* $egOwlApDBName: name of the postgres database to connect to
* $egOwlApUser: user for select queries
* $egOwlApPassword: password for queries except select
* $egOwlApPasswordGet:  password of $egOwlApUser
* $egOwlApSearchPath: search path for the database