Untitled
unknown
plain_text
a year ago
1.8 kB
1
Indexable
Never
from cassandra.cluster import Cluster from cassandra.auth import PlainTextAuthProvider import random import uuid import datetime contact_points = ['172.16.177.58'] auth_provider = PlainTextAuthProvider('hobs_analytics', 'hobs_analytics') cluster = Cluster(contact_points=contact_points, auth_provider=auth_provider) session = cluster.connect() query = "INSERT INTO hobs_ods_staging.hos_cart_details(hoscd_businessid,hoscd_valuetype,hoscd_key,hoscd_buId,hoscd_createdTime,hoscd_opId,hoscd_status,hoscd_type,hoscd_updatedTime,hoscd_username,hoscd_value,hoscd_event_date) VALUES (%s, %s, %s, %s, %s,%s,%s,%s,%s,%s,bigintAsBlob(%s),%s)" for i in range(100): user_list = ['tcs1','tcs2','tcs3','tcs4','tcs5'] businessid = ['cfl','jfl','tataplay','tcs'] value_type = ['text','number'] key = ["test1","test2","test3"] status = ['J'] type = ['str','int','float'] value = [1,2,3,4,5,6,7,8,9] username = random.choice(user_list) createdTime = datetime.datetime.now() - datetime.timedelta(seconds=random.randint(0, 100)) updatedTime = datetime.datetime.now() - datetime.timedelta(seconds=random.randint(0, 100)) event_date = createdTime.date() valuetype = random.choice(value_type) key = random.choice(key) status = random.choice(status) type = random.choice(type) value = random.choice(value) businessid = random.choice(businessid) #opId = uuid.uuid4() #buId = uuid.uuid4() #session.execute(query, (userID, createdTime, updatedTime, 'HOBS', 'DEFAULT')) session.execute(query,(businessid,valuetype,key,'DEFAULT',createdTime,'HOBS',status,type,updatedTime,username,value,event_date)) #session.shutdown() #cluster.shutdown() print("completed")