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??
-
No, unluckily we can not help you without your code and a proper error description. – Klaus D. Mar 14 '18 at 13:10
-
Please provide a minimal, complete and verifiable example. A description of how to do this is here: https://stackoverflow.com/help/mcve – Lars Gendner Mar 14 '18 at 13:10
-
[Solution](https://stackoverflow.com/a/75639931/6013016) – Scott Mar 05 '23 at 02:49
2 Answers
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.

- 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
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

- 13
- 2
-
Thank you brother. for that we need remote access for my live database server?? – Shafiul Alam Mar 15 '18 at 12:46
-
yeah you can, add the host of the mysql database in the host param – Joey Daniel Darko Mar 15 '18 at 14:24