from cassandra.cluster import Cluster
from cassandra import ConsistencyLevel as Level
from cql_builder.assignment import *
from cql_builder.condition import *
from cql_builder.builder import QueryBuilder

if __name__ == '__main__':

	keyspace = 'test_keyspace'
	column_family = 'people'
	session = Cluster(['localhost']).connect()

	# Insert
	insert = (QueryBuilder.insert_into(keyspace, column_family)
		.values(first='foo', last='bar')
		.using(ttl=3600)
	)
	session.execute(*insert.statement(consistency=Level.LOCAL_ONE))

	(QueryBuilder.insert_into(keyspace, column_family)
		.values(first='foo', age=13, friends=['joe', 'schmoe'])
		.using(ttl=10800)
	)

	# Update
	(QueryBuilder.update(keyspace, column_family)
		.using(ttl=3600)
		.set(Set(age=13))
		.where(all_eq(first='foo', last='bar'))
	)

	(QueryBuilder.update(keyspace, column_family)
		.using(ttl=3600)
		.set(Set(age=13))
		.where(
			eq('first', 'foo'),
			eq('last', 'bar')
		)
	)

	(QueryBuilder.update(keyspace, column_family)
		.set(Set(first='foo'))
		.where(
			gt('age', 13),
			lte('age', 25)
		)
	)

	(QueryBuilder.update(keyspace, column_family)
		.set(Set(age=13))
		.where(within('names', ['foo', 'bar']))
	)

	(QueryBuilder.update(keyspace, column_family)
		.set(SetAt('names', 'first', 'foo'))
		.where(all_eq(last='bar'))
	)

	(QueryBuilder.update(keyspace, column_family)
		.set(Add('ages', set([13, 25])))
		.where(eq('last', 'bar'))
	)

	(QueryBuilder.update(keyspace, column_family)
		.set(Set(interests={'sports': 'football', 'language': 'python'}))
		.where(eq('last', 'bar'))
	)

@@ -329,21 +329,77 @@
 ()%0A%0A%09# I
-nsert
+NSERT INTO ... (first, last) VALUES (foo, bar) USING TTL 3600
 %0A%09insert
@@ -575,16 +575,109 @@
 _ONE))%0A%0A
+%09# INSERT INTO ... (first, age, friends) VALUES (foo, 13, %5B'joe', 'schmoe'%5D) USING TTL 10800%0A
 %09(QueryB
@@ -806,21 +806,84 @@
 %09)%0A%0A%09# U
-pdate
+PDATE ... USING TTL 3600 SET age=13 WHERE first='foo' AND last='bar'
 %0A%09(Query
@@ -999,32 +999,105 @@
 ast='bar'))%0A%09)%0A%0A
+%09# UPDATE ... USING TTL 3600 SET age=13 WHERE first='foo' AND last='bar'%0A
 %09(QueryBuilder.u
@@ -1220,32 +1220,87 @@
  'bar')%0A%09%09)%0A%09)%0A%0A
+%09# UPDATE ... SET first='foo' WHERE age%3E13 AND age%3C=15%0A
 %09(QueryBuilder.u
@@ -1405,24 +1405,79 @@
 25)%0A%09%09)%0A%09)%0A%0A
+%09# UPDATE ... SET age=13 WHERE names IN ('foo', 'bar')%0A
 %09(QueryBuild
@@ -1573,24 +1573,82 @@
 bar'%5D))%0A%09)%0A%0A
+%09# UPDATE ... SET names%5B'first'%5D = 'foo' WHERE last='bar'%0A
 %09(QueryBuild
@@ -1746,32 +1746,88 @@
 ast='bar'))%0A%09)%0A%0A
+%09# UPDATE ... SET ages=ages + %7B13, 15%7D WHERE last='bar'%0A
 %09(QueryBuilder.u
@@ -1924,16 +1924,106 @@
 '))%0A%09)%0A%0A
+%09# UPDATE ... SET interests=%7B'sports': 'football', 'language': 'python'%7D WHERE last='bar'%0A
 %09(QueryB

add cql equivalents to examples