Tip: creating a Xapian database in Python
18th of January 2010
This cost me some hair-pulling today as I was trying to write a custom test runner for a Django project I'm working on that creates a test Xapian database just for running the tests. Basically, you can't do this:
os.mkdir(database_file_path)
Because if you do you end up getting these strange DatabaseOpeningError exceptions. So, here's how you do it:
import xapian
xapian.WritableDatabase(database_file_path,
xapian.DB_CREATE_OR_OPEN)
xapian.WritableDatabase(database_file_path,
xapian.DB_CREATE_OR_OPEN)
Hopefully by blogging about this some other poor coder will save some time.
Tweet