Commits

Takeshi Komiya committed ad7232c

* Follow newest schema

  • Participants
  • Parent commits e63a3f5

Comments (0)

Files changed (1)

File utils/import_from_mysql.py

 from pit import Pit
 
 import models
+from dateutil import parser
 from google.appengine.ext import db
 
 
     else:
         return string
 
+def alltags(cn):
+    cn.query('SELECT * FROM tags')
+    tag_rs = cn.store_result()
+    for i in range(tag_rs.num_rows()):
+        r = tag_rs.fetch_row()[0]
+
+        tag = models.Tag(name=decode(r[1]),
+                         type_id=int(r[2]),
+                         order_id=int(r[3]))
+        yield tag
+
 def allmaps(cn):
     cn.query('SELECT * FROM maps')
     map_rs = cn.store_result()
                          name=decode(r[1]),
                          author=re.sub('[\r\n]', '', decode(r[2])),
                          description=decode(r[3]),
-                         edit_key=r[4])
+                         edit_key=r[4],
+                         created_at=parser.parse(r[6]),
+                         updated_at=parser.parse(r[7]))
         tags_for(cn, map)
 
         yield map
     cn = _mysql.connect(config['host'], config['user'],
                         config['passwd'], config['db'])
 
+    for tag in alltags(cn):
+        tag.put()
+
     for map in allmaps(cn):
         map.put()