Doug Hellmann committed 97ae257 Draft

initialize the database from within the documentation config file

  • Participants
  • Parent commits a3609e1

Comments (0)

Files changed (2)

File docs/Makefile

 	-rm -rf $(BUILDDIR)/*
-html: sampledatabase
 	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-.PHONY: sampledatabase
-	rm -f sampledata.db
-	sqlite3 sampledata.db < sampledata.sql
+# .PHONY: sampledatabase
+# sampledatabase:
+# 	rm -f sampledata.db
+# 	sqlite3 sampledata.db < sampledata.sql
 	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml

File docs/

 # All configuration values have a default; values that are commented out
 # serve to show the default.
-import sys, os
+import os
+import sqlite3
+import sys
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # How to display URL addresses: 'footnote', 'no', or 'inline'.
 #texinfo_show_urls = 'footnote'
+def setup(app):
+    print 'Initializing sample database'
+    if os.path.exists('sampledata.db'):
+        os.unlink('sampledata.db')
+    with sqlite3.connect('sampledata.db') as conn:
+        with open('sampledata.sql', 'rt') as f:
+            schema =
+        conn.executescript(schema)