openstack, python

Connect to OpenStack MariaDB using PyMySQL

Many of OpenStack’s containerised services do not include a MySQL client, despite heavily relying on the MariaDB/Galera cluster. Instead, the services use the PyMySQL and SQLAlchemy python modules for this interaction.

Given that peeking into the database is a pretty common operation when troubleshooting issues in OpenStack, the lack of a MySQL client is a bit of a pain point. Yes, you can always jump on to one of the controllers, grab a shell in the Galera container, and have at it, but this may not be beneficial if you suspect a network or connectivity related issue.

Thankfully it is quite simple to just utilise PyMySQL directly.

Continue reading