Last active
December 14, 2015 11:29
-
-
Save ejucovy/5079195 to your computer and use it in GitHub Desktop.
Initializing a new trac database for an existing environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from trac.env import Environment | |
from trac.db import DatabaseManager | |
from trac import db_default | |
env = Environment("/path/to/my/env") | |
DatabaseManager(env).init_db() | |
with env.db_transaction as db: | |
for table, cols, vals in db_default.get_data(db): | |
db.executemany("INSERT INTO %s (%s) VALUES (%s)" % (table, ','.join(cols), ','.join(['%s' for c in cols])), vals) | |
import pkg_resources | |
from trac.wiki.admin import WikiAdmin | |
pages_dir = pkg_resources.resource_filename('trac.wiki', 'default-pages') | |
WikiAdmin(env).load_pages(pages_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment