Extension:Cargo/Exporting data

From MediaWiki.org
Jump to: navigation, search
Cargo - navigation
Basics Main pageExtension:Cargo (talk) · Download and installationExtension:Cargo/Download and installation · Quick start guideExtension:Cargo/Quick start guide · Other documentationExtension:Cargo/Other documentation · SMW migration guideExtension:Cargo/SMW migration guide
Using Cargo Storing dataExtension:Cargo/Storing data · Querying dataExtension:Cargo/Querying data (Display formatsExtension:Cargo/Display formats) · Browsing dataExtension:Cargo/Browsing data · Exporting dataExtension:Cargo/Exporting data · Other featuresExtension:Cargo/Other features
Resources for help Common problemsExtension:Cargo/Common problems · Known bugs and planned featuresExtension:Cargo/Known bugs and planned features · Getting supportExtension:Cargo/Getting support
About Cargo Authors and creditsExtension:Cargo/Authors and credits · Version historyExtension:Cargo/Version history · Sites that use CargoExtension:Cargo/Sites that use Cargo · Cargo and Semantic MediaWikiExtension:Cargo/Cargo and Semantic MediaWiki · FAQExtension:Cargo/FAQ

You can export the data contained in Cargo to use by other systems. There are various ways to do it: via display formats, via the API, and through direct SQL querying.

Export display formats[edit]

Queries in Cargo include three display formats that can be used for exporting data: "csv", "json" and "excel". If you set one of these as the display format, you will simply see a link as the query result. Clicking on that link will download a file (provided by the page Special:CargoExport) to the user's computer, that holds that structured data. Any outside system can also directly access that URL, if it has access to the wiki.

csv[edit]

The "csv" format has the following parameters, all optional:

  • delimiter - sets the separator character (default is comma)
  • link text - sets the text of the link (default is "View CSV", or the value at the page MediaWiki:cargo-viewcsv)
  • filename - sets the name of the file that is downloaded (default is "results.csv")

json[edit]

The "json" format has the following parameters, all optional:

  • link text - sets the text of the link (default is "View JSON", or the value at the page MediaWiki:cargo-viewjson)

excel[edit]

The "excel" format has the following parameters, all optional:

  • link text - sets the text of the link (default is "View XLS", or the value at the page MediaWiki:cargo-viewxls)
  • filename - sets the name of the file that is downloaded (default is "results.xls")

API[edit]

Cargo defines the "cargoquery" MediaWiki API action, which lets you call the equivalent of #cargo_query from an outside the wiki, returning the results in MediaWiki-specific JSON and XML formats. To see its usage syntax, search for "action=cargoquery" here.

Database querying[edit]

Finally, because Cargo stores its data in fairly simple database tables, you should be able to have other systems directly query its data using SQL, provided of course that they have access to that database. You can see an explanation of Cargo's data storage, including some special fields and tables, at Database storage details.