annotate web/hgbook/load_elements.py @ 838:d1f676a6a4b3 default tip

update mq chapter. propagate ef53d025f410.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 03 Dec 2009 01:26:08 +0900
parents 188efaefe001
children
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
687
188efaefe001 How to make all-ids.dat.
Bryan O'Sullivan <bos@serpentine.com>
parents: 673
diff changeset
11 os.system('make -C ../../en all-ids.dat')
673
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'