Company•May 10, 2019
KillrVideo Python Pt. 5— When Data Access is the Easiest Part of a Microservice
pip install dse-driver
# Wait for Cassandra (DSE) to be up, aka registered in etcd
{ "CONTACT_POINTS": ["10.0.75.1"], "DEFAULT_CONSISTENCY_LEVEL": "LOCAL_QUORUM" }
cluster = Cluster(contact_points=contact_points, execution_profiles={EXEC_PROFILE_DEFAULT: profile})
session = cluster.connect("killrvideo")
# retrieve the credentials for provided email from user_credentials table user_credentials = UserCredentialsModel.get(email=email)
# filter().all() returns a ModelQuerySet, we iterate over the query set to get the Model instances user_results = UserModel.filter(user_id__in=user_ids).all() users = list() for user in user_results: users.append(user) return users
SELECT * FROM killrvideo.users WHERE user_id IN <id1>, <id2>... </id2></id1>