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)

Hopefully by blogging about this some other poor coder will save some time.



Comment

Show all 4 comments
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.