I’m maintaining a tool called Fatameh on Wikimedia’s toolforge.
It’s a simple Django application that creates Wikidata items for users using OAuth. The idea is to let people make items for any academic paper just by providing an identifier.
It became popular as time went by and out-grew the sqlite backend. It was causing too much disk IO and so needed to be moved to the managed tools MariaDB cluster.
I’m a Django newbie and so something that I thought would be simple turned out not to be. Finding a suitable driver for MariaDB for my needs was harder than I thought.
Firstly it has to support the flavours of python and Django I was using. Specifically python 3 and Django 1.11.x
It then had the added complication that it would be run on the toolsforge kubernetes infrastructure in a special python 3 container. This is fairly cut down container that importantly doesn’t come with libmysqlclient. Unfortunately it seems of the three proposed drivers on the Django docs this restricts me to just one possibility: the mysql-connector library from oracle.
I try to add that using pip into my virtualenv: `pip install mysql-connector`
After some head scratching about a missing ProtoBuf library that I didn’t realise I needed it turns out that ‘mysql-connector’ isn’t the official library from oracle about provided by a 3rd party. This is always a problem when the official / bigger project get late to the party and hasn’t bagged the right name.
The official one seems to be `mysql-connector-python` but pip doesn’t actually have any versioned packages attached to this name it’s just a stub. Finally I realise it is called `mysql-connector-python-rf`.
This however *still* doesn’t work. Apparently it isn’t quite suited to Django 1.11 and only works with older versions. However yet more googling later I find some kind soul has written a few lines patch to make it play ball: mysql-connector-python
In the end this is what I used and it seems to work for now. Ideally we’ll move to the official oracle version if/when then they include this (simple looking to me) change for working with current Django.
I found it very surprising that using one of the most popular DBs with one the most popular frameworks was such a hassle and required finally using some 3rd party patch to make it all go.
Perhaps I missed something: all the django people I spoke to told me to use postgres instead or maybe it’s actually unusual for people to be without libmysqlclient. Either way, maybe this post will save the next uninitiated person the day I spent figuring this all out.