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


    Quote

    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.

    LibreELEC Wiki pages

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

    Blu-ray Disc Java menus support - forum thread, Github

    my lamp addon (unofficial/community) (limited no support)
    my touchscreen support and instructions by Grruhn (now touchscreen addon exists in repository)

  • 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

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

    5. nano Dockerfile


    Code
    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


    Code
    1. docker pull python

    7. Now build the docker image

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

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


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

    LibreELEC Wiki pages