2011-09-27, 17:17
how do I connect to mysql database from python in XBMC. and insert, update delete mysql table in python script? because at the time of calling a python script on XBMC have always failed script error?
import MySQLdb as mdb
import sys
def mySQLtest():
DB = 'test'
HOST = 'localhost'
DB_USER = 'root'
DB_PASSWORD = ''
conn = MySQLdb.Connection(db=test, host=DB_HOST, user=DB_USER,
passwd=DB_PASSWORD)
cursor = conn.cursor()
sql = """show tables;"""
cursor.execute(sql)
results = cursor.fetchall()
cursor.close()
conn.close()
return results
import MySQLdb as mdb
import sys
def mySQLtest():
DB = 'test'
HOST = 'localhost'
DB_USER = 'root'
DB_PASSWORD = ''
conn = MySQLdb.Connection(db=test, host=DB_HOST, user=DB_USER,
passwd=DB_PASSWORD)
cursor = conn.cursor()
sql = """show tables;"""
cursor.execute(sql)
results = cursor.fetchall()
cursor.close()
conn.close()
return results