populate.py 562 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python3
  2. import datetime
  3. import json
  4. import os
  5. import lc.config as c
  6. import lc.model as m
  7. import lc.request as r
  8. def main():
  9. c.db.init("test.db")
  10. m.create_tables()
  11. u = m.User.get_or_none(name="gdritter")
  12. if not u:
  13. u = m.User.from_request(
  14. r.User(name="gdritter", password=os.getenv("PASSWORD", "behest").strip(),)
  15. )
  16. u.set_as_admin()
  17. c.log(f"created user {u.name}")
  18. with open("scripts/aisamanra.json") as f:
  19. u.import_pinboard_data(f)
  20. if __name__ == "__main__":
  21. main()