Search code examples
python-3.xkivymysql-connector-pythonkivymd

can't connect to mysql database on android KivyMD


here's my code, it works with no problems on my PC

    try:
        connection = mysql.connector.connect(host='sql12.freesqldatabase.com',
                                             database='database',
                                             user='username',
                                             password='password')
        sql_select_Query = "select * from movies"
        cursor = connection.cursor()

then i generate an apk file from KivyMD using Buildozer.


but i get this error when i test the apk file on my Android using Logcat, and the app closes without showing any messages

Error reading data from MySQL table 2003: can't connect to MySQL server on 
'sql12.freesqldatabase.com:3306' (7 No address associated with hostname)

i use mysql-connector 'version 2.2.9 module.


i've also included INTERNET permission in my buildozer.spec file

android.permissions = INTERNET


Solution

  • it seems that my Phone had some permission troubles with the app, after giving internet permission inside my Phone the code worked perfectly.