pip install odbm
from datetime import datetime, date import odbm # class User(odbm.Model): username = odbm.UnicodeProperty(primary_key=True) birthday = odbm.DateProperty(key='b') is_active = odbm.Property(key='a', default=True) is_admin = odbm.Property(key='r', default=False) created = odbm.DateTimeProperty(key='c') __filename__ = 'var/user.odbm.tch' __db_type__ = 'tc' # User(username='fizban', birthday=date(1917, 1, 1), created=datetime.now()).save() # dict-style : # db['fizban'] = {'b': timestamp , 'c': timestamp } # (. key=... property) # u = User.get('fizban') print u.birthday # datetime.date(1917, 1, 1) # u.is_active = False u.save() # for i in xrange(10): User(username=('test-%i' % i), birthday=date(1950 + i, 1, 1)).save() # User.find() # c birthday > 1955, username for obj in User.find( filter = lambda u: u.birthday.year > 1955, order = lambda u: u.username): print obj # print User.count(lambda u: u.username.startswith('f')) # 1 # print User.count() # 11 User.find_one().delete() print User.count() # 10
seconds to write/read 10000 rowspickle (write, read): (1.0030829906463623, 0.25429201126098633)odbm (write, read): (0.99477910995483398, 0.14065694808959961)pickle file size: 2768704odbm file size: 1348752
Source: https://habr.com/ru/post/J114300/More articles:Lightpack:アップロードして開く求職者向け-面接は5回までAndroid向けGeo Planner週末のGeohotは、法的防衛のための寄付金を集めRORルビー:オタク誌Notion InkとCCAvenueはAdamの支払い済み注文をキャンセルしますGoDaddyによる1.18ドメインKyivstar「失われた」加入者Dropboxにはどのくらいの情報が保存されていますか?GoogleはChromeのアドレスバーを削除する場合がありますAll Articles