9

I need a way to insert new articles straight into my MediaWiki database without damaging the wiki installation.

I'm guessing if I knew what tables/attributes MediaWiki inserts to when creating a new article then I could fill them in myself.

Does anyone know a better way or have any suggestions?

6 Answers6

5

I am the author of the Bulk Page Creator, nice to see it is still being used!!!

My latest MediaWiki Import tool creates pages from a CSV data file and page template. It generates Mediawiki XML Import files as suggested by Adrian.

Check it out

Mediawiki CSV Import

JCutrer
  • 328
  • 3
  • 11
  • I have read many pages about adding new article, how about categories, does media wiki create a category tree separately? I think first step of migrating from a totally different data base to media wiki is creating categories, isn't it? – hpaknia Jun 11 '13 at 07:19
4

Out of many bots and APIs available for MediaWiki, a simple place to begin is the MediaWiki Bulk Page creator.

It is a simple PHP script, relying on the Snoopy class library, that can create several pages from a simple text format.

Before getting started, make sure you read Creating a Bot first. it contains critical details on how to set up bot access to your wiki.

bluish
  • 26,356
  • 27
  • 122
  • 180
Laurent Alquier
  • 514
  • 2
  • 4
  • Very helpful, got this up and running with my rss script in about 30 minutes. Thanks! –  Jul 09 '09 at 23:23
2

Definitely you don't want to write to the database directly. You may want to create an extension that takes selected items from RSS as input and creates one wiki article per item, using Article::doEdit().

Joshua C. Lerner
  • 1,910
  • 17
  • 12
2

You should do this with a bot. Bots can be run standalone, but if you're integrating with other code, you might want to pick based on the language. For PHP, there is the MediaWiki Bulk Page Creator. For Python, pymediawiki comes with Pagefromfile.

There is also an extension by Yaron Koren called External Data which solves a related task. It lets you incorporate data from external sources into your wiki pages. You can pull specific elements from CSV, XML or JSON -- retrieved from URLs, local files, or database.

Matt G
  • 2,373
  • 1
  • 14
  • 12
1

Why do you need to do this?

  • If you are trying to migrate data from a previous wiki installation, there exist import and export tools already.
  • If you want to automate the addition of a large set of pre-formatted pages automatedly, the MediaWiki API provides a safer route than mucking with the database directly.
ephemient
  • 198,619
  • 38
  • 280
  • 391
  • I am writing a php script to lists various RSS feeds from which the user can select articles to add into the wiki. I'm not too sure on how to use the API for this as I've never used it before. Is it possible to create several pages at once (depending on how many articles the user has selected) using the API? –  Jul 07 '09 at 21:25
  • I'm not sure if you can create many pages in a single call without using `action=import`, but you can just invoke `action=edit` multiple times, once for each new page you wish to create. – ephemient Jul 07 '09 at 21:33
  • I can probably use cURL to send multiple calls to the API. I'm having trouble figuring out how to use/create an edit token or specifying which user to do the posting with. Otherwise I'm on the right track. Thanks for the help. –  Jul 07 '09 at 21:56
1

Export pages with Special:Export

Import pages using Special:Import. Note that you have to have the 'import' user right to be able to import.

Community
  • 1
  • 1
Adrian Archer
  • 2,323
  • 1
  • 17
  • 20