python connection to MySQL

  • I would like to run some SQL queries in a python script on my LibreELEC box but I can not figure out what library to use.

    I tried


    import MySQLdb

    import mysql.connector

    I can not seem to find documentation about how to install python module on LibreELEC. I know the OS is read only. Any help would be appreciated.

  • AFAIK you cannot do what you require. You could wait for someone more experienced to reply, try OSMC which does not have the install restrictions, or look for a docker solution. Or try all of the them.

  • MySQLdb for python is available in entware. Too bad we don't have it in LE ;)

    Done giving support here because of last events.

  • Too bad as well. :/ So:

    The hard way.

    1. Install docker: Add-ons --> Install from repository --> LibreELEC Add-ons --> Services -- Docker.

    Once finished: Login with ssh.

    2. mkdir /storage/<Working Directory>

    3. cd <Working Directory>

    4. nano pip-requirements.txt

    1. mysql-python
    2. mysql-connector-python

    5. nano Dockerfile

    1. FROM python:2
    2. WORKDIR /storage/<Working directory>
    3. COPY pip-requirements.txt ./
    4. RUN pip install --no-cache-dir -r pip-requirements.txt
    5. COPY . .
    6. CMD [ "python", "/storage/<Working directory>/<Name of your script>.py" ]

    6. Now install docker python

    1. docker pull python

    7. Now build the docker image

    1. docker build -t <Name of your script>.py .

    8 ...... and if all goes well, run it

    1. docker run -it --rm --name <What it is know as> <Name of your script>.py