odbm
====

Installation
------------

    $  pip install tclite

Usage
-----
    >>> import tclite as tl
    >>> from datetime import datetime, date
    
    >>> class User(tl.Model):
    ...     username    = tl.UnicodeField(key='u')  # realy stored by short 'u' key
    ...     birthday    = tl.DateField()
    ...     rating      = tl.IntegerField(default=0)
    ...     reply_rate  = tl.FloatField(default=0) 
    ...     about_me    = tl.CompressedUnicodeField(internal_encoding='cp1251')
    ...     friends     = tl.DumpField(default=[]) 
    ...     messages    = tl.CompressedDumpField(default=[])
    ...     is_active   = tl.BooleanField(default=True)
    ...     created     = tl.DateTimeField(index=True) # indexed field
    ...
    ...     __filename__ = 'var/readme_test.tclite'
    
    >>> User.db.clear()
    >>> for i in xrange(100):
    ...     User(
    ...         username='user-%s' % i,
    ...         birthday=date(1900 + i, 1, 1),
    ...         created=datetime.now()
    ...     ).save()

    >>> users = User.filter('birthday >=', date(1950, 1, 1))
    >>> users.count()
    50
    
    >>> for user in users.filter('username endswith', '0').order('-created'):
    ...     user.username
    u'user-90'
    u'user-80'
    u'user-70'
    u'user-60'
    u'user-50'
    
    >>> users.get().username
    u'user-50'
    
    >>> users.delete()
    >>> users.count()
    0
    >>> User.filter().count()
    50
    
    >>> User(username='Foo', key='user-foo').save()  # set custom key name
    >>> User.get('user-foo').username  # get by keyname
    u'Foo'
