--- a/scripts/migrate_shorturls.py Sun Jan 20 01:52:00 2008 +0000
+++ b/scripts/migrate_shorturls.py Thu Jan 31 17:28:02 2008 +0000
@@ -19,33 +19,36 @@
type, dirpath, fname = value
- if type == "img" :
- id = shorturl.key2int(key)
+ id = shorturl.key2int(key)
+ dirpath = dirpath.lstrip('.').lstrip('/')
- dirpath = dirpath.lstrip('.').lstrip('/')
+ if type == "img" :
+ print "img"
+ continue # already imported images
- print "%6d %50s %10s" % (id, dirpath, fname)
+ print "img %6d %50s %10s" % (id, dirpath, fname)
yield id, dirpath, fname
- count += 1
+ else :
- if count % 500 == 0 :
- print count
- else :
- print "dir"
+ print "dir %6d %50s" % (id, dirpath)
+
+ yield id, dirpath, ''
+
+ count += 1
+
+ if count % 500 == 0 :
+ print count
+
print "Starting import..."
-c = db.cursor()
-
-c.executemany("""
- INSERT INTO images VALUES (?, ?, ?)
+c = db.insert_many("""
+ INSERT OR IGNORE INTO nodes VALUES (?, ?, ?)
""", gen())
print "Done!"
-print "%d rows affected" % c.rowcount
+print "%d rows affected" % c
-c.execute("SELECT id FROM images").fetchall()
-