Setting up SQL on Docker


I’m trying to setup MSSQL as an recorder for my HASS setup hosted on a Synology in a Docker container.
I can see from the documentation ( that I have to install some dependencies, but when I try to run them I get the following error;

[email protected]:/usr/src/app# sudo su -s /bin/bash homeassistant
bash: sudo: command not found

How can I fix this?
Thank you in advance

Do you mean MySQL?
Not sure, but i think you should not install mysql inside the HA docker container.
Install a mysql/mariadb docker container on your synology.

You have two options for an SQL database on a Synology. Install the MariaDB package from the package center or as VDRainer suggested, run a MySQL/MariaDB docker container. I used to do the former but recently switched to the latter and actually had some performance improvements by using a docker container.

I already got an MS SQL container running, but according to the documentation I need pymssql installed in my Home Assistant container. When I try to install it, I get the error.

You don’t install things in a docker container.

So there is no way I can make it work, when I’m missing pymssql?

What I have found typically in the Docker image, that all the dependencies for everything is already installed. Have you tried to connect to the database?

Another thing you can do is learn how a dockerfile works, and build your own docker image with the dependencies you need. There are ways to accomplish the end goal, you just need to learn how docker works first.

Maybe file an issue on github.
The docs say it should work.

Home Assistant uses SQLAlchemy as Object Relational Mapper (ORM). This means that you can now use any SQL backend for the recorder that is supported by SQLAlchemy, like MySQL, MariaDB, PostgreSQL, or MS SQL Server.

Yea, I get the following error when I try to connect:

Error (Recorder) [homeassistant.components.recorder] Error during connection setup: No module named ‘pymssql’

So, you should use the dockerfile that home assistant uses to create the image, and extend it to add what you need, then use that local image. Perhaps submit a request on GitHub to have it added to the base build?

Thank you, I’ve made an request now. Fingers crossed :slight_smile:


How did this end? Did you manage to find a way to add DB drivers to HASS.IO container?

Connections to MSSQL is working now for me in Hassio. I’m on HA 0.87.1. Recorder is logging history events and states to a MSSQL database. Just an FYI…

What does the connection string look like for the recorder db_url? The example looks specific to those package deps?