Skip to content

Instantly share code, notes, and snippets.

@sw897
Created April 1, 2014 03:34
Show Gist options
  • Save sw897/9907229 to your computer and use it in GitHub Desktop.
Save sw897/9907229 to your computer and use it in GitHub Desktop.
create_dashdoc_index
import os
import sqlite3
conn = sqlite3.connect('docSet.dsidx')
cur = conn.cursor()
cur.execute("DROP INDEX IF EXISTS anchor")
cur.execute("DROP TABLE IF EXISTS searchIndex")
cur.execute("CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT)")
cur.execute("CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path)")
for root, dirs, files in os.walk('Documents'):
for name in files:
(name2, ext) = os.path.splitext(name)
if ext.lower() == '.html':
type = 'Function'
if name2[0:3] == 'RT_':
name2 = name2[3:]
sql = "INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('%s', '%s', '%s')" % (name2, type, name)
cur.execute(sql)
conn.commit()
conn.close()
print('ok')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment