Я не могу понять, что не так в моем коде.
Я неправильно использовал executemany?
Код:
class SQLTester(DirectHandler):
def get_handler(self):
from google.appengine.api import rdbms
command = u"""INSERT IGNORE INTO `ClickLog`
(`action` ,`trace_code` ,`url` ,`secret` ,`facebook_id` ,`ip` ,`time` ,`tag` ,`from_url` ,`to_url`)
values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s);"""
conn = rdbms.connect(instance="tagtoosql:tagtoo", database='mysql')
cursor = conn.cursor()
#logs = mydb.iter(ClickLog.all(), 500)
logs = ClickLog.all().fetch(100)
values = []
for k in logs:
values.append((k.action,
k.trace_code,
k.url,
k.secret,
k.facebook_id,
k.ip,
mydb.to_timestamp1000(k.time),
k.tag,
k.from_url,
k.to_url))
if len(values) == 100:
cursor.executemany(command, values)
values = []
cursor.executemany(command, values)
Сообщение об ошибке:
Debug Stack: ExceptionType: <type 'exceptions.KeyError'>
ExceptionValue: [KeyError(<class 'google.appengine.api.datastore_types.Text'>,)]
Traceback (most recent call last):
File "/base/data/home/apps/s~tagtoo-now-news/worker.356508952957634250/libs/handlers.py", line 331, in get
self.get_handler(*args, **atts)
File "/base/data/home/apps/s~tagtoo-now-news/worker.356508952957634250/dashboard/backend.py", line 509, in get_handler
cursor.executemany(command, values)
File "/base/python_runtime/python_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 352, in executemany
self.execute(statement, args)
File "/base/python_runtime/python_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 293, in execute
bv.type, bv.value = self._EncodeVariable(arg)
File "/base/python_runtime/python_lib/versions/1/google/storage/speckle/python/api/rdbms.py", line 242, in _EncodeVariable
value = self._conn.encoders[type(arg)](arg, self._conn.encoders)
KeyError: <class 'google.appengine.api.datastore_types.Text'>