示例#1
0
class TestQuery(BaseTestInput):
    def setUp(self):
        super(TestQuery, self).setUp()

        self.frame = CassandraFrame([["VIN1", "ford", "black", "frank"],
                                     ["VIN2", "cyrsler", "blue", "chris"],
                                     ["VIN3", "honda", "red", "harry"]],
                                    columns=self.cols,
                                    session=self.session,
                                    table="tester")

        self.frame.create_cql_insert()

    def test_all_attributes(self):
        self.frame.insert_async()
        result_set = self.session.execute("SELECT * FROM tester")
        self.cf = result_set._current_rows

        self.assertEqual(len(self.cf), 3)
        self.assertIsInstance(self.cf, CassandraFrame)
        self.assertEqual(self.frame.session, self.cf.session)
示例#2
0
class TestQuery(BaseTestInput):

    def setUp(self):
        super(TestQuery, self).setUp()

        self.frame = CassandraFrame([["VIN1", "ford", "black", "frank"],
                                     ["VIN2", "cyrsler", "blue", "chris"],
                                     ["VIN3", "honda", "red", "harry"]],
                                    columns=self.cols, session=self.session, table="tester")

        self.frame.create_cql_insert()


    def test_all_attributes(self):
        self.frame.insert_async()
        result_set = self.session.execute("SELECT * FROM tester") 
        self.cf = result_set._current_rows

        self.assertEqual(len(self.cf), 3)
        self.assertIsInstance(self.cf, CassandraFrame)
        self.assertEqual(self.frame.session, self.cf.session)
示例#3
0
                    );""")

cols = ["id", "car", "color", "owner"]

session = cl.connect("tests")

#df = pd.DataFrame(range(1,5), columns=["a"])
#tmp = CassandraFrame(np.random.randn(10, 2), columns=["id",""], session = session, table="albums")

tmp = CassandraFrame(
    [["VIN1", "ford", "black", "frank"], ["VIN2", "cyrsler", "blue", "chris"],
     ["VIN3", "honda", "red", "harry"]],
    columns=cols,
    session=session,
    table="albums")
tmp.create_cql_insert()
tmp.insert_async()

print "Now see that the data was inserted"
session.execute("""SELECT id, car, color, owner FROM tests.albums""")

print "The description of tests.albumns:"
print cl.keyspaces["tests"].tables["albums"]
print "As opposed to this:"
print cl.metadata.keyspaces["tests"].tables["albums"].export_as_string()

print "Another comparison"
print cl.keyspaces["tests"].tables["sold_cars"]
print "As opposed to this:"
print cl.metadata.keyspaces["tests"].tables["sold_cars"].export_as_string()
示例#4
0
                       color text,
                       owner text,
                       passengers set<text>,
                       data blob
                    );""")

cols = ["id","car","color","owner"]

session = cl.connect("tests")

#df = pd.DataFrame(range(1,5), columns=["a"])
#tmp = CassandraFrame(np.random.randn(10, 2), columns=["id",""], session = session, table="albums")

tmp = CassandraFrame([["VIN1", "ford", "black", "frank"], ["VIN2", "cyrsler", "blue", "chris"], ["VIN3", "honda", "red", "harry"]],
                                  columns = cols, session=session, table="albums")
tmp.create_cql_insert()
tmp.insert_async()

print "Now see that the data was inserted"
session.execute("""SELECT id, car, color, owner FROM tests.albums""")

print "The description of tests.albumns:"
print cl.keyspaces["tests"].tables["albums"].describe()
print "As opposed to this:"
print cl.metadata.keyspaces["tests"].tables["albums"].export_as_string()

print "Another comparison"
print cl.keyspaces["tests"].tables["sold_cars"].describe()
print "As opposed to this:"
print cl.metadata.keyspaces["tests"].tables["sold_cars"].export_as_string()