0

I am in problem to connect online live mysql with python 3.4. i want to develop a kivy mobile app using mysql but i could not make the connection. Can anybody help me??

2 Answers2

0

This is a very VERY bad idea from a security standpoint. This would expose your database to all sorts of attacks from anyone. Theoretically they would have to guess the database username and password but hoping that brute force won't be a big deal is not enough. Not to mention the amount of load if someone starts attacking you. I can keep chewing this topic for days so instead this is a good way to start if you are interested.

Instead you should ditch this plan and go for something more secure. There are plenty of python web frameworks that you could use to develop API's and use REST to communicate with the database. Tornado, Django, Flask, cherrypy, all perfectly valid options.

Cons:

  • You'll have to develop and maintain a second project.
  • You must make sure that it's got backwards compatibility whenever you roll out an update.

Pros:

  • Scalability options(multiple severs, replication, load balancing).
  • Ability to seamlessly change database engines(given the migration is correct).
  • Secured firewall rules.
  • Sanitized and validated user inputs.
  • User data would be far better protected.

Connecting directly from the application exposes way too many risks.

Alexander Ejbekov
  • 5,594
  • 1
  • 26
  • 26
  • Thank You Alex. But i need to connect directly to the mysql database its project requirement. Can you please give me the asn. how can i do this. – Shafiul Alam Mar 14 '18 at 13:27
0

you can connect to the database you want with any sql client available ,eg: pymysql,sqlalchemy or peeewee. But since you are going to do this with kivy, i would recommend peewee because it is also fast and lightweight. Just add the name,password, user and address to the database like this

from peewee import *
import peewee as pw
myDB = pw.MySQLDatabase("ahmedparxx_db", host="ahxxxy.com", port=3306, 
user="ahmxxx", passwd="050xxx")

Since this is an orm, read the docs on mapping the various tables to your class

class Person(Model):
    name = CharField()
    number = IntegerField()

    class Meta:
        database = myDB

for person in Person.select():
    print(person.name, person.number)

the code above shows how to retrieve info.. Good Luck