Untitled
unknown
plain_text
2 years ago
3.1 kB
1
Indexable
Never
below one is cache_store.py in models directory from flask_cqlalchemy import CQLAlchemy import uuid from datetime import datetime db=CQLAlchemy() def serializetojson(self): results = {} for key in self.keys(): if type(self[key]) in [str,int,bool,float,dict]: results[key] = self[key] elif type(self[key]) == type(None): results[key] = None elif type(self[key]) is list: lst = [] for x in self[key]: lst.append(x) results[key] = lst elif type(self[key]) in [ uuid.UUID ,datetime]: results[key] = str(self[key]) elif type(self[key]==bytes): results[key] = str(self[key].decode('utf-8')) else: results[key] = str(type(self[key])) return results class cache_store(db.Model): __keyspace__ = 'hobs_ods_staging' businessid = db.columns.Text(primary_key=True) valuetype = db.columns.Text(primary_key=True) key = db.columns.Text(primary_key=True) buid = db.columns.Text() createdtime = db.columns.DateTime() opid = db.columns.Text() updatedtime = db.columns.DateTime() username = db.columns.Text() value = db.columns.Blob() type = db.columns.Text() def __json__(self): results = serializetojson(self) return results db.sync_table(cache_store) below code is from indexes from model directory which iam importing from flask_cqlalchemy import CQLAlchemy db=CQLAlchemy() def serializetojson(self): results = {} for key in self.keys(): if type(self[key]) in [str,int,bool,float]: results[key] = self[key] elif type(self[key]) == type(None): results[key] = None elif type(self[key]) is list: lst = [] for x in self[key]: lst.append(x.__json__()) results[key] = lst else: results[key] = str(type(self[key])) return results class columns(db.Model): __keyspace__ = 'system_schema' clustering_order = db.columns.Text() keyspace_name = db.columns.Text(primary_key=True) table_name = db.columns.Text(primary_key = True) column_name = db.columns.Text(primary_key =True) column_name_bytes = db.columns.Blob() kind = db.columns.Text() position = db.columns.Integer() type = db.columns.Text() def __json__(self): results = serializetojson(self) return results db.sync_table(columns) below code is from indexes in models directory from flask_cqlalchemy import CQLAlchemy db=CQLAlchemy() def serializetojson(self): results = {} for key in self.keys(): if type(self[key]) in [str,int,bool,float,dict]: results[key] = self[key] elif type(self[key]) == type(None): results[key] = None elif type(self[key]) is list: lst = [] for x in self[key]: lst.append(x.__json__()) results[key] = lst else: results[key] = str(type(self[key])) return results class indexes(db.Model): __keyspace__ = 'system_schema' keyspace_name = db.columns.Text(primary_key=True) table_name = db.columns.Text(primary_key=True) index_name = db.columns.Text(primary_key=True) kind = db.columns.Text() options = db.columns.Map(db.columns.Text(),db.columns.Text()) def __json__(self): results = serializetojson(self) return results db.sync_table(indexes)