2014-06-14 23 views
1

XBMC 미디어 응용 프로그램 용 버전 2.6을 사용하여 파이썬 스크립트에서 작업하고 있습니다.python 오류 바인딩 매개 변수 0 - 아마도 지원되지 않는 유형

파이썬 스크립트에 문제가 있습니다. 오류가 발생합니다. 오류 내용 : 매개 변수 0을 바인딩하는 중 오류가 발생했습니다. 지원되지 않는 유형 일 수 있습니다.

오류

이 줄에 점프 같습니다 XBMC 로그 여기

import xbmc 
import xbmcgui 
import xbmcaddon 
import os 
import urllib2 
import StringIO 
import sqlite3 
from sqlite3 import dbapi2 as database 
from xml.etree import ElementTree 
import xml.etree.ElementTree as ET 
from UserDict import DictMixin 
import datetime 
import time 

class MyClass(xbmcgui.WindowXML): 

    def onAction(self, action): 

     #DOWNLOAD THE XML SOURCE HERE 
     url = ADDON.getSetting('allchannels.url') 
     req = urllib2.Request(url) 
     response = urllib2.urlopen(req) 
     data = response.read() 
     response.close() 
     profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', '')) 

     if os.path.exists(profilePath): 
      profilePath = profilePath + 'source.db' 
      con = database.connect(profilePath) 
      cur = con.cursor() 
      cur.execute('CREATE TABLE programs(channel TEXT, title TEXT, start_date TIMESTAMP, stop_date TIMESTAMP, description TEXT)') 
      con.commit() 
      con.close 
      tv_elem = ElementTree.parse(StringIO.StringIO(data)).getroot() 
      profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', '')) 
      profilePath = profilePath + 'source.db' 
      con = sqlite3.connect(profilePath) 
      cur = con.cursor() 
      channels = OrderedDict() 

      # Get the loaded data 
      for channel in tv_elem.findall('channel'): 
      channel_name = channel.find('display-name').text 
      for program in channel.findall('programme'): 
       title = program.find('title').text 
       start_time = program.get("start") 
       stop_time = program.get("stop") 
       cur.execute("INSERT INTO programs(channel, title, start_date, stop_date)" + " VALUES(?, ?, ?, ?)", [channel_name, title, start_time, stop_time]) 
       con.commit() 
       print 'Channels store into database are now successfully!' 


      program = None 
      now = datetime.datetime.now() 
      #strCh = '(\'' + '\',\''.join(channelMap.keys()) + '\')' 
      cur.execute('SELECT * FROM programs WHERE channel=? AND start_date <= ? AND stop_date >= ?', [channel, now, now]) 
      row = cur.fetchone() 
      if row: 
       programming = program(row['channel'], row['title'], row['start_date'], row['stop_date']) 
       cur.close() 

됩니다 :

- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS! 
Error Type: <class 'sqlite3.InterfaceError'> 
Error Contents: Error binding parameter 0 - probably unsupported type. 
Traceback (most recent call last): 
File "C:\Users\user\AppData\Roaming\XBMC\addons\script.tvguide\test.py", line 1682, in onAction 
cur.execute('SELECT * FROM programs WHERE channel=? AND start_date <= ? AND stop_date >= ?', [channel, now, now]) 
InterfaceError: Error binding parameter 0 - probably unsupported type. 
-->End of Python script error report<-- 
+0

을 그리고'channel'의 유형은 무엇입니까? –

+0

@CL. '채널'은 없다. 나는 sqlite 데이터베이스에서 채널을 찾고 싶다. 도울 수 있니? –

+0

@ CL. 너는 어떤 생각을 가지고 있니? –

답변

0

대신

cur.execute('SELECT * FROM programs WHERE channel=? AND start_date <= ? AND stop_date >= ?', [channel, now, now]) 
다음

cur.execute('SELECT * FROM programs WHERE channel=? AND start_date <= ? AND stop_date >= ?', [channel, now, now]) 

하면 코드,210

이 시도 :

inq='SELECT * FROM programs WHERE channel=' + str(channel) + ' AND ' start_date <=' + str(now) + ' AND stop_date >= ' + str(now) 

cur.execute (inq)