Last active
February 4, 2016 18:34
-
-
Save beccam/17a704584596590b6311 to your computer and use it in GitHub Desktop.
Getting Started with Apache Cassandra Part III (cqlengine)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cqlengine import columns | |
from cqlengine.models import Model | |
class Users(Model): | |
firstname = columns.Text() | |
age = columns.Integer() | |
city = columns.Text() | |
email = columns.Text() | |
lastname = columns.Text(primary_key=True) | |
def __repr__(self): | |
return 'user(firstname=%s, age=%d)' % (self.firstname, self.age) | |
from cqlengine import connection | |
connection.setup(['127.0.0.1'], "demo") | |
from cqlengine.management import sync_table | |
sync_table(Users) | |
Users.create(firstname='Bob', age=35, city='Austin', email='[email protected]', lastname='Jones') | |
q=Users.get(lastname='Jones') | |
print q | |
q.update(age=36) | |
print q | |
q.delete() | |
q=Users.objects() | |
for i in q: print i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
q=Users.objects.all() can just be User.objects()