description | Python library for schema-less, sharded data (ala CouchDB, FriendFeed) |
homepage URL | http://github.com/bickfordb/waffle/tree/master |
repository URL | https://github.com/bickfordb/waffle.git |
owner | srinivasanr@gmail.com |
last change | Wed, 8 Jul 2009 05:06:28 +0000 (7 22:06 -0700) |
last refresh | Sat, 31 Oct 2009 21:18:28 +0000 (31 22:18 +0100) |
mirror URL | git://repo.or.cz/waffle.git |
https://repo.or.cz/waffle.git | |
ssh://git@repo.or.cz/waffle.git | |
bundle info | waffle.git downloadable bundles |
content tags |
Waffle is a Python library for storing data in a schema-less, document oriented way using a relational database
Similar designs:
Advantages:
Disadvantages:
Requirements So Far
Small Example:
import time
import sqlalchemy
import waffle
_engines = [
sqlalchemy.create_engine('sqlite:///:memory:'),
sqlalchemy.create_engine('sqlite:///:memory:'),
]
# Define a blog post entity that's searchable by time
def to_time(record):
yield {'time': int(time.mktime(record.created.timetuple()))}
time_idx = waffle.Index('blog_time',
columns=[sqlalchemy.Column('time', sqlalchemy.Integer())],
shard=waffle.ShardByPrimaryKey(_engines),
mapper=to_time)
class BlogPost(waffle.Record):
def __init__(self, **kwargs):
kwargs.setdefault('value', {'body': '', 'title': ''})
super(BlogPost, self).__init__(**kwargs)
blog_posts = waffle.Entity('blog', engines=_engines, indices=[time_idx], record_class=BlogPost)
# Create the table and indices if they don't already exist
blog_posts.create()
# Make a new blog post
blog_post = blog_posts.new()
blog_post.value['title'] = 'My First Blog Post'
blog_post.value['body'] = 'It\'s a sunny day in San Francisco.'
# Save it
blog_posts.save(blog_post)
# Print the blog posts for today:
# (prints => My First Blog Post)
for blog_post in blog_posts.select(time_idx.c.time >= (time.time() - 86400)):
print blog_post.value['title']
14 years ago | master | logtree |