KwikiData is a MediaWiki extension that extracts template data and stores them in an SQL database. The database becomes a live, read-only mirror of the structured information in the wiki.

Source: Can be found on BitBucket (download)

KwikiData depends on the light-weight KwiDatabase2 database abstraction layer.

Source: KwiDatabase2.php (download) page for the extension


At Student Business Relations, we've been experimenting with storing contact information on the user pages of our MediaWiki installation. For this purpose, we use a template, like this:

| name = Søren Løvborg
| messenger =

We already present this information in an organized way on the wiki itself using the DynamicPageList2 extension, but had no way to extract the information for use outside the wiki.

Enter the KwikiData extension, which automatically replicates template information into a separate MySQL database.

How it works

First, you must create a separate schema (in MySQL also known as a database) for the extracted wiki data. Example:

CREATE SCHEMA `wikidata`;

Then you create one table for each template you're interested in (e.g. "User"). The tables should consist of one column for each template parameter you're interested in, plus a column to store the page title (the primary key). Example:

CREATE TABLE `wikidata`.`User` (
  `_page` varchar(255) NOT NULL,
  `_timestamp` int NOT NULL,
  `name` varchar(255),
  `messenger` varchar(255),
  `phone` varchar(255),
  PRIMARY KEY (`_page`)

The template parameter columns must allow NULL values.

Now you just need to configure your MediaWiki installation to use KwikiData, and you'll have a populated "User" table in no time.

The database is automatically updated when saving an article, but "sysop" users can also request a complete update by adding ?action=updateAllKwikiData to any wiki URL.


Start by adding the following two lines to your LocalSettings.php:

$wgAutoloadClasses['KwiDatabase2'] = "$IP/extensions/KwiDatabase2.php";
"$IP/extensions/KwikiData.setup.php" );

You may additionally set a number of variables to configure KwikiData. These must be set after require_once, and their default values can be found at the end of KwikiData.setup.php.

Database options

KwikiData needs a database connection to store template data, and is currently unable to re-use the MediaWiki connection. Instead, it needs a KwiDatabase2 database connection. (I'm unsure if it's even possible to use the MediaWiki connection, due to the highly specialized nature of the MediaWiki database abstraction layer, and the fact that we're accessing data in another schema.)

You may set $wgKwikiDataDSN to a specific PDO (PHP Data Objects)) DSN (Data Source Name, AKA connection string). If you don't, KwikiData automatically tries to connect to the same database server that the rest of the MediaWiki installation uses.

The database user name and password is set using $wgKwikiDataUser and $wgKwikiDataPassword; these default to the same credentials as used for the main MediaWiki database.

By default, data is stored in the schema (AKA database) "wikidata", but this can be overriden using $wgKwikiDataSchema. If using a non-MySQL database server, you may also need to set $wgKwikiDataCatalog; this has not been tested, so caveat emptor.


Send questions, complaints, praise, bug reports and patches to the author.

By sending patches to the author, you agree to license them under the same terms as KwikiData itself ("GNU GPL 2 or later").

Other database engines than MySQL

KwikiData has only been tested agains MySQL, though some preliminary support for other database backends has been added. Bug reports and patches are welcome.


CC-GNU GPL This software is licensed under the GNU GPL version 2.0 and any later version.