WARFRAME Wiki
Advertisement
WARFRAME Wiki
Photo-4
“It's taking longer than I calculated.”
This page is actively being worked on and may not be completely correct. Please assist in making this page accurate. See WARFRAME Wiki:Research on ways to perform research on this game. Click here to add more info.

While we don't recommend the use of data stored on Lua subpages on the wiki (a.k.a "databases" or data stores) for production-level use cases, this article will describe some ways of transferring user-contributed open data on the wiki to other database formats for better querying, aggregation, and filtering of data not offered by hacking Lua tables to serve as data stores.

Serializing Lua Tables to JSON[]

Module:JSON allows the conversion of Lua tables to JSON string format. Users will typically have to convert the string into a proper JSON object/file before being able to import data into other database formats.

In Debug Console[]

Users can produce a JSON string output by running the following snippet on any module's debugging console (accessed by editing the page's source code):

=require("Module:JSON").stringify(p)

or

=require("Module:JSON").stringify(mw.loadData("Module:DatabaseName/data"))

Using MediaWiki Action API[]

An API call can be made to generate the JSON string output of any Lua module by running a Lua script remotely in the wiki's MediaWiki environment (action=scribunto-console) and fetching the resultant JSON string output. The JSON string output will be under the return key. See Special:ApiSandbox for an interactive API endpoint builder and mw:API:Main page for more documentation.

Sample[]

Sample endpoint for getting the JSON string output of Module:Resources/data:

In Special:ApiSandbox:

JSON to SQL/NoSQL[]

Users would have create a script that parses through the JSON file and map keys to their correct data type. Data schemas are documented on the respective Lua module's /doc subpage. For example, Module:Resources/data's schema is documented on Module:Resources/data/doc.

Note that some data schemas include nested objects so these Lua tables are harder to convert to a SQL-compatible format. You would need to somehow unnest/flatten these objects and define new keys or create new tables that are referenced by unique ids for join operations.

Serializing Lua Tables to CSV[]

Module:CSV allows the conversion of Lua tables to Comma-separated values (CSV) string format. Note that this script does not work well for databases with nested objects so some manipulation is initially needed to unnest/flatten objects before being able to output the data to CSV.

In Debug Console[]

Users can produce a CSV string output by running the following snippet on any module's debugging console (accessed by editing the page's source code):

=require("Module:CSV").encode(p)

or

=require("Module:CSV").encode(mw.loadData("Module:DatabaseName/data"))

Example[]

Module:Weapons/csv is a Lua submodule that produces a CSV string output of the contents in Module:Weapons/data. The resultant string output can be found on Weapon Comparison/CSV.

See Also[]

Advertisement