sqlite3.OperationalError: nierozpoznany token: znacznik danych „01T00” Pythona
Mam problem z wstawieniem wartości do bazy danych SQLite. Dane, które pobieram z norweskiego parlamentu data.stortinget.no. Błąd, który otrzymuję: sqlite3.OperationalError: nierozpoznany token: „01T00”
Oto metoda, w której występuje błąd: (Wiem o błędzie wcięcia w tym fragmencie)
def get_perioder(cur):
DOK = "stortingsperioder"
try:
page = urllib2.urlopen(SITE+DOK)
except:
print "Failed to fetch item "+DOK
if page:
tree = ElementTree.parse(page)
root = tree.getroot()
top = list(root)[2]
elements = list(top)
for el in elements:
fra = el.find('{http://data.stortinget.no}fra').text
per_id = el.find('{http://data.stortinget.no}id').text
til = el.find('{http://data.stortinget.no}til').text
print "id: %s fra: %s til: %s" % (per_id, fra, til)
cur.execute("INSERT INTO perioder(fra, id, til) VALUES(%s,%s,%s)" % (fra, per_id, til))
else:
print "Could not load page: "+DOK
Wiadomość wydrukowana przez wydruk tuż powyżej cur.execute brzmi: id: 2009-2013 fra: 2009-10-01T00: 00: 00 do: 2013-09-30T23: 59: 59 Cały ślad błędu:
BigMac:Stortingsdata ola$ python getBasicData.py
id: 2009-2013 fra: 2009-10-01T00:00:00 til: 2013-09-30T23:59:59
Traceback (most recent call last):
File "getBasicData.py", line 169, in <module>
get_perioder(cur)
File "getBasicData.py", line 26, in get_perioder
cur.execute("INSERT INTO perioder(fra, id, til) VALUES(%s,%s,%s)" % (fra, per_id, til))
sqlite3.OperationalError: unrecognized token: "01T00"
Nawiązałem do instrukcji SQLite i wygląda na to, że format jest obsługiwany, więc zastanawiam się, skąd pochodzi problem.