Skip to content

Instantly share code, notes, and snippets.

@berry
Created March 28, 2010 15:06
Show Gist options
  • Save berry/346795 to your computer and use it in GitHub Desktop.
Save berry/346795 to your computer and use it in GitHub Desktop.
#<Keyspace Name="MapData">
# <ColumnFamily CompareWith="BytesType" Name="Points"/>
# <ColumnFamily CompareWith="LongType" Name="Lons"/>
#</Keyspace>
import struct
import binascii
from lazyboy import *
from lazyboy.key import Key
def _i64(n):
return struct.pack('>q', n) # big endian = network order
# Define your cluster(s)
connection.add_pool('MapData', ['localhost:9160'])
class Lon(record.Record):
_keyspace = "MapData"
_column_family = "Lons"
class Point(record.Record):
_keyspace = "MapData"
_column_family = "Points"
data = {"lon": "5.0", "name":"test"}
p = Point()
p.set_key(key=data['name'])
p.update(data)
p.save()
print p.key, p
l = Lon()
l.set_key(key=_i64(7888))
l.update(data)
print "=" * 10
print l.is_modified()
print l.key
print l
l.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment