Add connection pool for database connections
Pull connectins from the pool when doing queries in a thread
mysql-python (and all mysql drivers I can find) have a threadsafety
value of 1 (see PEP-249) which makes it unsafe to use the same
connection from more than one thread.
Trivia in particular used to do this extensively, which is what prompted
https://gitlab.com/rizon/mysql-python/commit/
c09cfd229176bd280bfb0384aaed7d07c42bbc0a,
however this fix is not correct because both mysql_query and
mysql_store_result both need to be called in the mutex lock, which this
doesn't do. However this fixes segfaults from causing libmysqlclient
going multithreaded, so it works well enough in production.