dump-blobs.py 389 B

123456789101112131415161718192021222324
  1. import sqlite3
  2. import os
  3. con = sqlite3.connect('cache.db')
  4. con.row_factory = sqlite3.Row
  5. def write_file(row):
  6. filename = "./blobs/{}.dif".format(row["hash"][:40])
  7. print(filename)
  8. with open(filename, "wb") as f:
  9. f.write(row["data"])
  10. try:
  11. os.mkdir('blobs')
  12. except FileExistsError:
  13. pass
  14. cursor = con.execute("select * from blobs")
  15. for row in cursor.fetchall():
  16. write_file(row)