2014-10-27, 21:26
Hi, i'm currently creating my first addon, and i'm stuck with getting a csv-file to MySQL using myconnpy's mysql.connector
For some reason it keeps throwing me back the following error:
I've got the following code so far:
If i use MySQLdb.connector outside of XBMC, it works as it should. After some searching around i've found the following article:
http://stackoverflow.com/questions/15336...ith-python
however, i'm not sure how to use the buffered option. Can somebody clarify?
For some reason it keeps throwing me back the following error:
Code:
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'modules.mysql.connector.errors.InternalError'>
Error Contents: Unread result found.
Traceback (most recent call last):
File "C:\Users\paulvw\AppData\Roaming\XBMC\addons\plugin.video.wintersportersv1\default.py", line 94, in <module>
__import__(module)
File "C:\Users\paulvw\AppData\Roaming\XBMC\addons\plugin.video.wintersportersv1\modules\xbmcdatacollector.py", line 321, in <module>
wintersporters_op_vimeo_MySQL(vimeo_db)
File "C:\Users\paulvw\AppData\Roaming\XBMC\addons\plugin.video.wintersportersv1\modules\xbmcdatacollector.py", line 215, in wintersporters_op_vimeo_MySQL
""", (vimeo_id, vimeo_title, vimeo_description, upload_date, mobile_url, thumbnail_small, thumbnail_medium, thumbnail_large, user_id, user_name, user_url, user_portrait_small, user_portrait_medium, duration, width, height, tags, embed_privacy, vimeo_title, vimeo_description, upload_date, mobile_url, thumbnail_small, thumbnail_medium, thumbnail_large, user_id, user_name, user_url, user_portrait_small, user_portrait_medium, duration, width, height, tags, embed_privacy))
File "C:\Users\paulvw\AppData\Roaming\XBMC\addons\plugin.video.wintersportersv1\modules\mysql\connector\cursor.py", line 296, in execute
raise errors.InternalError("Unread result found.")
InternalError: Unread result found.
I've got the following code so far:
Code:
def csv_to_MySQL(csvfile)
database=open(csvfile)
vimeo_db = csv.reader(database, delimiter=';')
database = mysql.connector
db = database.connect(host=mysqlhost, user=mysqluser, passwd=mysqlpass, db=mysqldb)
cursor = db.cursor()
cursor.execute("SELECT * FROM vimeo")
for row in vimeo_db:
vimeo_id = row[0]
vimeo_title = row[1]
vimeo_description = row[2]
upload_date = row[3]
mobile_url = row[4]
thumbnail_small = row[5]
thumbnail_medium = row[6]
thumbnail_large = row[7]
user_id = row[8]
user_name = row[9]
user_url = row[10]
user_portrait_small = row[11]
user_portrait_medium = row[12]
duration = row[13]
width = row[14]
height = row[15]
tags = row[16]
embed_privacy = row[17]
cursor.execute ("""
INSERT INTO vimeo SET vimeo_id=%s, vimeo_title=%s, vimeo_description=%s, upload_date=%s, mobile_url=%s, thumbnail_small=%s, thumbnail_medium=%s, thumbnail_large=%s, user_id=%s, user_name=%s, user_url=%s, user_portrait_small=%s, user_portrait_medium=%s, duration=%s, width=%s, height=%s, tags=%s, embed_privacy=%s
ON DUPLICATE KEY UPDATE vimeo_title=%s, vimeo_description=%s, upload_date=%s, mobile_url=%s, thumbnail_small=%s, thumbnail_medium=%s, thumbnail_large=%s, user_id=%s, user_name=%s, user_url=%s, user_portrait_small=%s, user_portrait_medium=%s, duration=%s, width=%s, height=%s, tags=%s, embed_privacy=%s
""", (vimeo_id, vimeo_title, vimeo_description, upload_date, mobile_url, thumbnail_small, thumbnail_medium, thumbnail_large, user_id, user_name, user_url, user_portrait_small, user_portrait_medium, duration, width, height, tags, embed_privacy, vimeo_title, vimeo_description, upload_date, mobile_url, thumbnail_small, thumbnail_medium, thumbnail_large, user_id, user_name, user_url, user_portrait_small, user_portrait_medium, duration, width, height, tags, embed_privacy))
cursor.close()
db.commit()
db.close()
If i use MySQLdb.connector outside of XBMC, it works as it should. After some searching around i've found the following article:
http://stackoverflow.com/questions/15336...ith-python
however, i'm not sure how to use the buffered option. Can somebody clarify?