Пример #1
0
def main(argv):
  print "************************* cassandra test START" 
  print py_cassandra.version()
  
  users_columns = ["email","pw","date_creation","date_change","date_last_login","applications","appdrop_rem_token", "appdrop_rem_token_exp","visit_cnt",  "cookie", "cookie_ip","cookie_exp", "cksum"]
  users_values = ["*****@*****.**", "11", "2009", "2009", "2009", "bbs", "xxx", "xxx","1", "yyy", "0.0.0.0", "2009", "zzz"]
  
  apps_columns = ["name", "version","owner","admins_list","host","port","creation_date",  "last_time_updated_date", "yaml_file",  "cksum", "num_entries"]
  apps_values = ["name",  "version","owner","admins_list","host","port","creation_date",  "last_time_updated_date", "yaml_file",  "cksum", "num_entries"]
    
  TABLE_NAME = "AppScale"
  COLUMN_FAMILY="appscale"
  TABLE= "AppScale"
  FAMILY="appscale"
  KEY = "test"
  COLUMN = "column1"
  VALUE = "value1"
  
  
  # key, family, column, value 
  # print py_cassandra.test_insert(KEY, COLUMN, VALUE) 
  # family(table_name), row_key 
  # print py_cassandra.get_row(FAMILY, KEY)
   
  #create table .. : tablename(family), schema list
  
  #print py_cassandra.create_table("apps", apps_columns)
  #print py_cassandra.get_schema("apps")
  #print py_cassandra.create_table("users", users_columns)
  #print py_cassandra.get_schema("users")
  #print py_cassandra.get_row_count("apps") [1:]
  #print py_cassandra.get_row_count("users") [1:]
   
  
  #print py_cassandra.put_entity("users", "users_suwanny", users_columns, users_values) 
  #print py_cassandra.get_row("users", "users_suwanny")[1:]
  
  print "before keys", py_cassandra.get_keys()
  
  column_names = ["name", "email", "date_creation", "column3"] 
  values = ["value1", "value2","value3", "value4"]
  values2 = ["value2-1", "value2-2","value2-3", "value2-4"]
  table = "temp" 
  key = "test_1"
  key2 = "test_2"

  #print "create table", py_cassandra.create_table(table, column_names)
  #print "get_schema", py_cassandra.get_schema(table)[1:]
  #print "row_count", py_cassandra.get_row_count(table)[1:]
  #print "put_entity", py_cassandra.put_entity(table, key, column_names, values) 
  #print "put_entity", py_cassandra.put_entity(table, key2, column_names, values2) 
  #print "get_row", py_cassandra.get_row(table, key)[1:] 
  #print "delete_row", py_cassandra.delete_row(table, key) 
  #print "get_entity", (py_cassandra.get_entity(table, key2, column_names))[1:] 
  
  #print "get_table", py_cassandra.get_table(table, column_names)[1:] 
  print "put_entity", py_cassandra.put_entity("temp2", "test3", column_names, values) 
  print "get_schema", py_cassandra.get_schema("temp2")[1:]
  print "get_table", py_cassandra.get_table("temp2", column_names)[1:] 
  # everything is sorted by alphabet order ..   
    
  print "after keys", py_cassandra.get_keys()
  print "************************* cassandra test END" 
Пример #2
0
def main(argv):
    print "************************* cassandra test START"
    print py_cassandra.version()

    users_columns = [
        "email", "pw", "date_creation", "date_change", "date_last_login",
        "applications", "appdrop_rem_token", "appdrop_rem_token_exp",
        "visit_cnt", "cookie", "cookie_ip", "cookie_exp", "cksum"
    ]
    users_values = [
        "*****@*****.**", "11", "2009", "2009", "2009", "bbs", "xxx", "xxx",
        "1", "yyy", "0.0.0.0", "2009", "zzz"
    ]

    apps_columns = [
        "name", "version", "owner", "admins_list", "host", "port",
        "creation_date", "last_time_updated_date", "yaml_file", "cksum",
        "num_entries"
    ]
    apps_values = [
        "name", "version", "owner", "admins_list", "host", "port",
        "creation_date", "last_time_updated_date", "yaml_file", "cksum",
        "num_entries"
    ]

    TABLE_NAME = "AppScale"
    COLUMN_FAMILY = "appscale"
    TABLE = "AppScale"
    FAMILY = "appscale"
    KEY = "test"
    COLUMN = "column1"
    VALUE = "value1"

    # key, family, column, value
    # print py_cassandra.test_insert(KEY, COLUMN, VALUE)
    # family(table_name), row_key
    # print py_cassandra.get_row(FAMILY, KEY)

    #create table .. : tablename(family), schema list

    #print py_cassandra.create_table("apps", apps_columns)
    #print py_cassandra.get_schema("apps")
    #print py_cassandra.create_table("users", users_columns)
    #print py_cassandra.get_schema("users")
    #print py_cassandra.get_row_count("apps") [1:]
    #print py_cassandra.get_row_count("users") [1:]

    #print py_cassandra.put_entity("users", "users_suwanny", users_columns, users_values)
    #print py_cassandra.get_row("users", "users_suwanny")[1:]

    print "before keys", py_cassandra.get_keys()

    column_names = ["name", "email", "date_creation", "column3"]
    values = ["value1", "value2", "value3", "value4"]
    values2 = ["value2-1", "value2-2", "value2-3", "value2-4"]
    table = "temp"
    key = "test_1"
    key2 = "test_2"

    #print "create table", py_cassandra.create_table(table, column_names)
    #print "get_schema", py_cassandra.get_schema(table)[1:]
    #print "row_count", py_cassandra.get_row_count(table)[1:]
    #print "put_entity", py_cassandra.put_entity(table, key, column_names, values)
    #print "put_entity", py_cassandra.put_entity(table, key2, column_names, values2)
    #print "get_row", py_cassandra.get_row(table, key)[1:]
    #print "delete_row", py_cassandra.delete_row(table, key)
    #print "get_entity", (py_cassandra.get_entity(table, key2, column_names))[1:]

    #print "get_table", py_cassandra.get_table(table, column_names)[1:]
    print "put_entity", py_cassandra.put_entity("temp2", "test3", column_names,
                                                values)
    print "get_schema", py_cassandra.get_schema("temp2")[1:]
    print "get_table", py_cassandra.get_table("temp2", column_names)[1:]
    # everything is sorted by alphabet order ..

    print "after keys", py_cassandra.get_keys()
    print "************************* cassandra test END"
Пример #3
0
#print py_cassandra.put_entity("__hi__", key, columns, data)
#print py_cassandra.put_entity("__hah__", key, columns, data)
#exit(0)
print py_cassandra.put_entity(table_name, key, columns, data)
ret = py_cassandra.get_entity(table_name, key, columns)
print "doing a put then get"
print ret
if ret[1:] != data:
  print "ERROR doing a put then get. Data does not match"
  print "returned: " + str(ret)
  print "expected: " + str(data)
  exit(1)
else: 
  print "Success"

ret = py_cassandra.get_schema("hello")
print ret
print "checking schema:"
print ret
if ret[1:] != columns:
  print "ERROR in recieved schema"
  print "returned: " + str(ret)
  print "expected: " + str(columns)

ret = py_cassandra.delete_row(table_name, key)
print "Deleting the key %s"%key
print ret

ret = py_cassandra.get_entity(table_name, key, columns)
print "Trying to get deleted key:"
print ret