Commits

Takeshi Komiya committed ef1cf56

* Clear datastore before importing database

Comments (0)

Files changed (1)

utils/import_from_mysql.py

     return polylines
 
 
+def delete_all(model):
+    count = model.all().count()
+    print "deleting %s ... (%d)" % (model.__name__, count)
+
+    for o in model.all().fetch(1000):
+        o.delete()
+
+    count = model.all().count()
+    if count > 0:
+        delete_all(model)
+
+
 def main():
     config = Pit.get('gmappers', {'require': {'host': 'localhost',
                                               'user': 'gmappers',
     cn = _mysql.connect(config['host'], config['user'],
                         config['passwd'], config['db'])
 
+    delete_all(models.Tag)
+    delete_all(models.Map)
+    delete_all(models.Marker)
+    delete_all(models.Polyline)
+
     for tag in alltags(cn):
         tag.put()