Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
798 B

  1. #!/usr/bin/env python3
  2. # Create a metadata.db in ~/notes
  3. import os
  4. import sqlite3
  5. os.chdir(os.path.join(os.getenv('HOME'), 'notes'))
  6. conn = sqlite3.connect('metadata.db')
  7. c = conn.cursor()
  8. c.execute(
  9. '''CREATE TABLE links (
  10. page text,
  11. target text,
  12. UNIQUE(page, target)
  13. );
  14. '''
  15. )
  16. c.execute(
  17. '''CREATE TABLE pages (
  18. page text,
  19. title text,
  20. datetime text,
  21. UNIQUE(page)
  22. );
  23. '''
  24. )
  25. c.execute(
  26. '''CREATE INDEX "links_page_idx" ON "links" (
  27. "page"
  28. );
  29. '''
  30. )
  31. c.execute(
  32. '''CREATE INDEX "links_target_idx" ON "links" (
  33. "target"
  34. );
  35. '''
  36. )
  37. c.execute(
  38. '''CREATE INDEX "pages_page_idx" ON "pages" (
  39. "page"
  40. );
  41. '''
  42. )
  43. conn.commit()
  44. conn.close()