2011-10-20, 15:30
i have some problem with xbmc, when i use python connect to mysql with pyhton script it can update, select, delete database on mysql. but when i combine python script to xbmc xml it can't connect to database this is my log from xbmc.log :
08:54:50 T:2972699504 M:372703232 NOTICE: -->Python Interpreter Initialized<--
08:54:50 T:2972699504 M:372703232 ERROR: Error Type: exceptions.ImportError
08:54:50 T:2972699504 M:372695040 ERROR: Error Contents: No module named MySQLdb
08:54:50 T:2972699504 M:372695040 ERROR: Traceback (most recent call last):
File "/home/xbmc/.xbmc/script/sql.py", line 4, in ?
import MySQLdb as mdb
ImportError: No module named MySQLdb
and this is my sql.py :
import MySQLdb
conn = mySQLdb.Connect(host='localhost',user='ivan',\
password='ivan123',database='ivan')
c = conn.cursor()
c.execute("""drop table if exists towns""")
c.execute("""drop table if exists hotels""")
conn.commit()
c.execute("""create table towns (
tid int primary key not NULL ,
name text,
postcode text)""")
c.execute("""create table hotels (
hid int primary key not NULL ,
tid int,
name text,
address text,
rooms int,
rate float)""")
c.execute("""insert into towns values (1, "Melksham", "SN12")""")
c.execute("""insert into towns values (2, "Cambridge", "CB1")""")
c.execute("""insert into towns values (3, "Foxkilo", "CB22")""")
c.execute("""insert into hotels values (1, 2, "Hamilkilo Hotel", "Chesterton Road", 15, 40.)""")
c.execute("""insert into hotels values (2, 2, "Arun Dell", "Chesterton Road", 60, 70.)""")
c.execute("""insert into hotels values (3, 2, "Crown Plaza", "Downing Street", 100, 105.)""")
c.execute("""insert into hotels values (4, 1, "Well House Manor", "Spa Road", 5, 80.)""")
c.execute("""insert into hotels values (5, 1, "Beechfield House", "The Main Road", 26, 110.)""")
conn.commit()
c.execute ("""select * from towns left join hotels on towns.tid = hotels.tid""")
for row in c:
print (row)
c.close()
from the log import MySQLdb as mdb
ImportError: No module named MySQLdb
can anyone advise me how can i solve this problem
08:54:50 T:2972699504 M:372703232 NOTICE: -->Python Interpreter Initialized<--
08:54:50 T:2972699504 M:372703232 ERROR: Error Type: exceptions.ImportError
08:54:50 T:2972699504 M:372695040 ERROR: Error Contents: No module named MySQLdb
08:54:50 T:2972699504 M:372695040 ERROR: Traceback (most recent call last):
File "/home/xbmc/.xbmc/script/sql.py", line 4, in ?
import MySQLdb as mdb
ImportError: No module named MySQLdb
and this is my sql.py :
import MySQLdb
conn = mySQLdb.Connect(host='localhost',user='ivan',\
password='ivan123',database='ivan')
c = conn.cursor()
c.execute("""drop table if exists towns""")
c.execute("""drop table if exists hotels""")
conn.commit()
c.execute("""create table towns (
tid int primary key not NULL ,
name text,
postcode text)""")
c.execute("""create table hotels (
hid int primary key not NULL ,
tid int,
name text,
address text,
rooms int,
rate float)""")
c.execute("""insert into towns values (1, "Melksham", "SN12")""")
c.execute("""insert into towns values (2, "Cambridge", "CB1")""")
c.execute("""insert into towns values (3, "Foxkilo", "CB22")""")
c.execute("""insert into hotels values (1, 2, "Hamilkilo Hotel", "Chesterton Road", 15, 40.)""")
c.execute("""insert into hotels values (2, 2, "Arun Dell", "Chesterton Road", 60, 70.)""")
c.execute("""insert into hotels values (3, 2, "Crown Plaza", "Downing Street", 100, 105.)""")
c.execute("""insert into hotels values (4, 1, "Well House Manor", "Spa Road", 5, 80.)""")
c.execute("""insert into hotels values (5, 1, "Beechfield House", "The Main Road", 26, 110.)""")
conn.commit()
c.execute ("""select * from towns left join hotels on towns.tid = hotels.tid""")
for row in c:
print (row)
c.close()
from the log import MySQLdb as mdb
ImportError: No module named MySQLdb
can anyone advise me how can i solve this problem