Help talk:Tool Labs/Database

Rendered with Parsoid
From Wikitech
Latest comment: 8 years ago by Spacemartin in topic Static MediaWiki

remote databases

grep '^192\.168\.99\.' /etc/hosts > labsdb.hosts seems broken. I guess everything is 10.* now. For my usecase I only need enwiki.labsdb, that points to 10.64.4.11

So you can connect via mysql --defaults-file="${HOME}"/replica.my.cnf -h 10.64.4.11 enwiki_p

--physikerwelt (talk) 16:09, 17 January 2015 (UTC)Reply

text table

Is this the right place to mention that many (all?) of the wikis replicated in labsdb instances don't have the text table populated but use a separate storage mechanism for revision text? It would have saved me several hours hacking at database code that was never going to work. GoldenRing (talk) 13:38, 9 April 2015 (UTC)Reply

Someone else asked at the parent talk page so expectations vary but are never fulfilled :-).
I don't know where I would put that information, and I am generally unhappy with the current documentation structure as it feels too wordy to me and the multiple pages/collapsed sections unuseful because they hide information if you search for it with Google Chrome. But I can't unlearn what I've got to know over the past years to make an educated decision about that.
So: Hey, it's a wiki! Be bold, etc. --Tim Landscheidt (talk) 22:29, 9 April 2015 (UTC)Reply

Access to multiple databases

Hi, I need to query multiple lang wikipedias. How can I do this without creating multiple connections?? --Kanzat (talk) 08:35, 2 May 2015 (UTC)Reply

You can access the databases with the corresponding prefixes, for example:
SELECT p1.page_id,
       p2.page_id
FROM enwiki_p.page AS p1
JOIN dewiki_p.page AS p2 USING (page_namespace,
                                page_title)
WHERE p1.page_namespace = 0
  AND p1.page_title = 'Hamburg';
--Tim Landscheidt (talk) 04:51, 3 May 2015 (UTC)Reply

PHP

So, if a tool gets mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock', what is it doing wrong? Context: phabricator:T107618. --Nemo 20:57, 31 July 2015 (UTC)Reply

Static MediaWiki

I'm thinking of trying to get MediaWiki to work with the Tool Labs replicas (read-only). I basically want to set up a filter that performs textual modifications to the pages before they are served - specifically, I want to add (approximate) Pinyin readings to Chinese text to help language learners. If anyone tries to edit a page, I will provide an explanation and a link to the source wiki. Has anyone done this sort of thing before/can anyone think of any snags I might run up against? Would this be considered a valid use of Tool Labs servers?

I have already noticed, as User:GoldenRing mentions, that the text tables are not present in the replicas. Can anyone tell me where they are?

If necessary, I will make a fork of MediaWiki that supports this sort of use so it will be easy to do in future.

--Spacemartin (talk) 14:16, 18 November 2015 (UTC)Reply

In the WMF cluster, the article contents are not stored in the database, but on separate servers. These are neither replicated to Labs nor can they be directly accessed otherwise. The most efficient way is probably RESTBase.
For your purposes, I would suggest to develop either a JavaScript gadget that users could individually enable on wiki or a MediaWiki extension. The former option is much easier to do and deploy than the latter. --Tim Landscheidt (talk) 04:48, 19 November 2015 (UTC)Reply
Too late! Pinyin Wiki :-) --Spacemartin (talk) 19:50, 20 November 2015 (UTC)Reply