I'm building an app for android and i need to interact with Mysql database. I have some problem at configuring access from android but not with my linux installation.
I have succesfully imported the recipe of SQLAlchemy on my android apk but when i run the app trough logcat i see the error:
NO module named MySQLdb
so i tried adding in buildozer also the recipe of MySQLdb and it says:
No matching distribution found for MySQLdb
This is the part of the code invoking mysql part:
import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy import MetaData, Column, Table, ForeignKey
from sqlalchemy import Integer, String
from sqlalchemy.sql import select
def check_sql_list(_id, string):
cur = engine.connect()
res = cur.execute("SELECT * FROM tbl_user")
for x in res.fetchall():
if x[_id] == string: return True
cur.close()
def create_user(name,e_mail,psw):
if check_sql_list(1,name):
print 'Select another username.'
elif check_sql_list(2,e_mail):
print 'Your E-Mail have already an account.'
else:
connection = engine.raw_connection()
try:
cursor = connection.cursor()
cursor.callproc("sp_createUser",[name, e_mail, psw])
results = list(cursor.fetchall())
for a in cursor.fetchall():
print a
print results
cursor.close
connection.commit()
finally:
connection.close()
print 'Account registered succesfully.'
ip = 'localhost'
databs = 'mydb'
user = 'guest'
psw = 'password'
porta = '3306'
engine = create_engine('mysql://' + user + ':' + psw + '@' + ip + ':' + porta + '/' + databs)
create_user('user001','mail@001.com','password')
How can i connect to my database without the needing of MySQLdb recipe? Or where i can find that recipe?
I answer to my own question hoping someone will find it usefull.
I find out how to solve it, use as a dialer mysql+mysqlconnector like:
engine = create_engine('mysql+mysqlconnector://user00:psw@localhost:3306/database')
and adds the recipe requirements in the buildozer.spec:
requirements = kivy,sqlalchemy,mysql_connector