This table is generated by querying the database replica by a bot.
Edits made within the table area will be removed on the next update!
This template uses Lua: |
This template summons a bot to update the page with the results of the provided database query. It must be "closed" with {{Database report end}}; the text between these two templates will be replaced by the bot-generated table. It is possible to have multiple reports in one page.
The table is updated by the bot whenever you click the "Update the table now" button, and can be configured to automatically update periodically by setting |interval=N
(one update every N days).
Some formatting options are provided which enable page titles to be wikilinked and article excerpts to be shown. For complex use cases, the row_template or postprocess_js options can be used which allow you to format the query output in arbitrary ways using wikimarkup, Lua or JavaScript.
This template is currently powered by SDZeroBot (source code). It populates Category:SDZeroBot database report subscriptions.
Don't know SQL? No worries. SDZeroBot's AutoSQL will help you get the SQL equivalent of a query written in plain English. It doesn't work all the time, sadly – in which case you can ask for help at WP:RAQ.
{{Database report
|sql =
SELECT page_title, rev_timestamp AS "Last revid", page_latest, page_len, actor_name AS Creator, user_editcount
FROM pagetriage_page
JOIN page on page_id = ptrp_page_id
JOIN revision ON page_id = rev_page AND rev_parent_id = 0
JOIN actor ON rev_actor = actor_id
LEFT JOIN user ON user_id = actor_user
WHERE page_namespace = 0
AND page_is_redirect = 0
AND ptrp_reviewed = 0
|wikilinks = 1, 5:2 <!-- Link 1st column to mainspace, 5th column to user namespace (ns 2) -->
|excerpts =
|comments =
|widths = 2:9em, 3:15em <!-- Set 2nd column width as 9em, 3rd column width to 15em -->
|interval = 7 <!-- Update once every 7 days -->
|table_style =
|pagination =
|max_pages =
}} ... (This will be overwritten by the bot) ... {{Database report end}}
LIMIT
clause to limit the output size, or use pagination. IMPORTANT: The query must execute within 10 minutes. The bot uses a server-side timeout – MariaDB's max_statement_time variable to prevent overload on the DB. This should only contain 1 SQL statement. Do not combine multiple statements with semicolons.{{
and }}
), wrap the SQL with <nowiki>...</nowiki>
.Database table references: page · revision · text · actor · user · main database layout manual page
wikilinks = 4
Links titles in the 4th column. Use this style if the column contains the full page name.wikilinks = 4:2
Links titles in 4th column to user (ns:2) namespace. Use this style if the column contains the page name without namespace.
wikilinks = 5:2:show
Links titles in 4th column to user (ns:2) namespace, and additionally adds the namespace prefix to the displayed text.wikilinks = 4:c3
Links the titles in 4th column using namespace number given in the third column. Applicable for queries like SELECT page_namespace, page_title from ...
that have both page title and namespace but in different columns.wikilinks = 4:c3:show
Same as above, but additionally put the namespace prefix in the displayed text.wikilinks = 2:2:show, 3:0
Links multiple columns! The configuration of each column (using one of the above styles) is comma-separated.wikilinks = 1:0, 2:2:show, 3:4
Adds links to three different columns: 1st column to mainspace, 2nd column to userspace making the "User:" prefix visible, and titles in 3rd column to WP space (with the namespace prefix piped).widths = 2:10em, 4:20px
forces the 2nd column to have a width of 10em and the 4th column to get a width of 20px.overflow-wrap: anywhere
which causes better overflow behaviour. To suppress the default, use overflow-wrap: normal
.wikitable sortable
.srcColumnNumber : destColumnNumber : namespace : charLimit : charHardLimit
c4
to get the namespace number from 4th column. This can be used as input to {{Namespace name}}, to return the actual name: "{{Namespace name|1}}:"
will return "Talk:" and "{{Namespace name|10}}:"
will return "Template:".|pagination=1000
is set and there are 4200 results, 1–1000 are saved to the page containing the query. 1001–2000 are saved to the /2
subpage, and so on. If unspecified, all results are saved on a single page. See also max_pages.skip_table
parameter. Values in the row are passed to the template as unnamed parameters (|1=
, |2=
, etc).
row_template
. Any value will work.row_template
as well, then the header template will be placed over the table, and table headers will still be generated.skip_table
. This could be used along with header_template
for collapsing (collapse top/collapse bottom) or creating columns (div col/div col end) in the generated content. No parameters are passed to the template. It can be substituted instead by specifying "subst:" before the template name. For quick reference: |}
is {{end}}.function postprocess(rows) {
// `rows` is an array.
// Each element in `rows` is an object with column names as keys, and with values stringified
// Eg. for SELECT page_namespace, page_title FROM page LIMIT 2
// the `rows` could be:
// [
// { page_namespace: '0', page_title: 'Main Page' },
// { page_namespace: '1', page_title: 'Main Page' },
// ]
// Write code to process rows here.
// Return it after modifications:
return rows;
}
<nowiki>...</nowiki>
.await bot.request('https://...')
provides readonly access to various Wikimedia APIs. Supported endpoints: en.wikipedia.org/api/rest_v1, wikimedia.org/api/rest_v1, en.wikipedia.org/w/rest.php, en.wikipedia/org/w/api.php, api.wikimedia.org and query.wikidata.org. These can be used for fetching pageview data (from REST API), ORES scores (from Lift Wing), and so on.await bot.api({action: 'query', ...})
can be alternatively used. Parameters action: 'query', format: 'json' and formatversion: 2 are set by default.DATE_FORMAT(rev_timestamp, '%Y-%m-%d %H:%i')
or DATE_FORMAT(rev_timestamp, '%Y-%m-%d')
.ROW_NUMBER() OVER(ORDER BY (SELECT 1)) AS "No."
. For example, see WP:Database reports/Fully salted titles with unusually long expiries.header_template = static row numbers
and table_class = wikitable sortable static-row-numbers static-row-header-text
.overflow-wrap: anywhere; word-break: break-word
can sometimes help avoid columns becoming too wide due to presence of long non-breaking text. This may cause even the headers to break mid-word, use widths to avoid that.SELECT page_namespace, page_title FROM ...
), use |wikilinks=2:c1:show
and then hide the namespace column from display (|hide=1
)."{{Namespace name|1}}:"
will return "Talk:" and "{{Namespace name|2302}}:"
will return "Gadget definition:".The design of the bot and template were inspired from User:ListeriaBot and {{Wikidata list}}.