0
我的 '学院' 模型数据是:如何出口GAE数据到mysql
alt text http://omploader.org/vNG9zNw
我str_loader.py是:
class MySQLExporter(bulkloader.Exporter):
def output_entities(self, entity_generator):
conn = MySQLdb.connect(host='localhost',user='root',passwd='root',db='test',charset="utf8")
c = conn.cursor()
for entity in entity_generator:
c.execute("INSERT INTO haha (a,b) VALUES (%s, %s)",
(entity['cid'], entity['name']))
class Mysql_download(MySQLExporter):
def __init__(self):
MySQLExporter.__init__(self,'College',
[
('cid', str,None),
('name', lambda x: unicode(x, 'utf8'),None),
])
exporters = [Mysql_download]
,它运行成功:
alt text http://omploader.org/vNG9zNA
但它没有向mysql插入数据:
alt text http://omploader.org/vNG9zNg
感谢
更新
现在已确定:
class MySQLExporter(bulkloader.Exporter):
def output_entities(self, entity_generator):
conn = MySQLdb.connect(host='localhost',user='root',passwd='root',db='test',charset="utf8")
c = conn.cursor()
for entity in entity_generator:
c.execute("INSERT INTO haha (a,b) VALUES (%s, %s)",
(entity['cid'], entity['name']))
conn.commit()
Nick,so cool .. – zjm1126 2010-06-19 20:22:38