DS201の実施_Drivers

DS201: Foundations of Apache Cassandra™ and DataStax Enterpriseの学習記録。

Pythonドライバを使用してApache Cassandraに接続する。

from cassandra.cluster import Cluster
cluster = Cluster(protocol_version = 3)
session = cluster.connect('killrvideo')

for val in session.execute("SELECT * FROM videos_by_tag"):
    print(val)
$ python test.py

Row(tag='datastax', added_date=datetime.datetime(2013, 10, 16, 9, 0), video_id=UUID('4845ed97-14bd-11e5-8a40-8338255b7e33'), title='DataStax Studio')
Row(tag='datastax', added_date=datetime.datetime(2013, 4, 16, 9, 0), video_id=UUID('5645f8bd-14bd-11e5-af1a-8638355b8e3a'), title='What is DataStax Enterprise?')
Row(tag='cassandra', added_date=datetime.datetime(2014, 1, 29, 9, 0), video_id=UUID('1645ea59-14bd-11e5-a993-8138354b7e31'), title='Cassandra History')
Row(tag='cassandra', added_date=datetime.datetime(2013, 3, 17, 9, 0), video_id=UUID('3452f7de-14bd-11e5-855e-8738355b7e3a'), title='Cassandra Intro')
Row(tag='cassandra', added_date=datetime.datetime(2012, 4, 3, 9, 0), video_id=UUID('245e8024-14bd-11e5-9743-8238356b7e32'), title='Cassandra & SSDs')
Tags: