annotate web/hgbook/load_elements.py @ 673:ad304b606163

Initial cut at web comment system import
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 10 Mar 2009 21:42:19 -0700
parents
children 188efaefe001
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
673
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1 #!/usr/bin/env python
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2 #
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
3 # This script updates the contents of the comments_element table.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
4 # It's fugly, but a lot less painful than trying to use Django's
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
5 # fixtures system.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
6
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
7 import os, sys
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
8 sys.path.append(os.path.dirname(__file__))
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
9 import dbutil
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
10
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
11 os.system('make -C ../../en ids')
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
12
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
13 conn = dbutil.connect()
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
14 c = conn.cursor()
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
15 c.execute('''load data local infile "../../en/all-ids.dat" replace
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
16 into table comments_element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
17 fields terminated by "|"''')
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
18 print 'Database updated'