- #!/usr/bin/env python3
-
- # Create a metadata.db in ~/notes
-
- import os
- import sqlite3
-
- os.chdir(os.path.join(os.getenv('HOME'), 'notes'))
-
- conn = sqlite3.connect('metadata.db')
- c = conn.cursor()
-
- c.execute(
- '''CREATE TABLE links (
- page text,
- target text,
- UNIQUE(page, target)
- );
- '''
- )
-
- c.execute(
- '''CREATE TABLE pages (
- page text,
- title text,
- datetime text,
- UNIQUE(page)
- );
- '''
- )
-
- c.execute(
- '''CREATE INDEX "links_page_idx" ON "links" (
- "page"
- );
- '''
- )
-
- c.execute(
- '''CREATE INDEX "links_target_idx" ON "links" (
- "target"
- );
- '''
- )
-
- c.execute(
- '''CREATE INDEX "pages_page_idx" ON "pages" (
- "page"
- );
- '''
- )
-
- conn.commit()
- conn.close()
|