Mercurial > hgbook
annotate web/hgbook/load_elements.py @ 749:7e7c47481e4f
Oops, this is the real merge for my hg's oddity
author | Dongsheng Song <dongsheng.song@gmail.com> |
---|---|
date | Fri, 20 Mar 2009 16:43:35 +0800 |
parents | 188efaefe001 |
children |
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' |