Various useful functions. Some can be imported from doqu.utils, some are available directly at doqu.
Storage adapter factory. Expects path to storage backend module and optional backend-specific settings. Returns storage adapter instance. If required underlying library is not found, exception pkg_resources.DistributionNotFound is raised with package name and version as the message.
Parameters: |
|
---|
Usage:
import doqu
db = doqu.get_db(backend='doqu.ext.shelve', path='test.db')
query = SomeDocument.objects(db)
Settings can be also passed as a dictionary:
SETTINGS = {
'backend': 'doqu.ext.tokyo_cabinet',
'path': 'test.tct',
}
db = doqu.get_db(SETTINGS)
The two methods can be combined to override certain settings:
db = doqu.get_db(SETTINGS, path='another_db.tct')
Returns a pretty readable name based on the class name. For example, “SomeClass” is translated to “some_class”.
Reads given file (assuming it is in a known format), loads it into given storage adapter instance and returns that instance.
Parameters: |
|
---|
Usage:
import doqu
db = doqu.load_fixture('account.csv')
query = SomeDocument.objects(db)