123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- from MyUtils.MetadataWebUtil import MetadataWebUtil
- class ZillionUtil():
- def __init__(self, url):
- self.metadata = MetadataWebUtil(url)
- ##列出所有数据库
- def database_list(self):
- param = {
- "QueryType": "database_list"
- }
- databases = self.metadata.get_hbase(param)
- return databases["Content"]
- # TODO 其他zillion语句
- ##列出所有数据库下的表(不包含分表)
- def table_list_strict(self,table):
- param = {
- "QueryType":"table_list_strict",
- "Database":table
- }
- databases = self.metadata.get_hbase(param)
- return databases["Content"]
- ##列出所有数据库
- # def query(self, database, table, Criteria):
- # param = {
- # "QueryType": "select",
- # "Database": database,
- # "Datatable": table,
- # "Criteria": Criteria
- # }
- # print(param)
- # databases = self.metadata.get_hbase(param)
- # return databases["Content"]
- def select(self, database, table, Criteria):
- param = {
- "QueryType": "select",
- "Database": database,
- "Datatable": table,
- "Criteria": Criteria
- }
- databases = self.metadata.get_hbase(param)
- return databases["Content"]
- def table_key(self, database, table):
- param = {
- "QueryType": "table_detail",
- "Database": database,
- "Datatable": table
- }
- databases = self.metadata.get_hbase(param)
- key = databases["Content"]["Key"]
- return key
- def select_count(self, database, table, Criteria):
- param = {
- "QueryType": "select_count",
- "Database": database,
- "Datatable": table,
- "Criteria": Criteria
- }
- databases = self.metadata.get_hbase(param)
- return databases["Count"]
- def query_data(self, sql):
- databases = self.metadata.get_hbase(sql)
- return databases["Content"]
- def insert(self,database,table,InsertObject):
- param = {
- "QueryType": "batch_insert",
- "Database": database,
- "Datatable": table,
- "InsertObjects": InsertObject
- }
- databases = self.metadata.get_hbase(param)
- return databases["Count"]
- def remove(self,database,table,key):
- param = {
- "QueryType": "remove",
- "Database": database,
- "Datatable": table,
- "Key": key
- }
- databases = self.metadata.get_hbase(param)
- return databases["Count"]
- def put(self,database,table,InsertObject):
- param = {
- "QueryType": "batch_put",
- "Database": database,
- "Datatable": table,
- "InsertObjects": InsertObject
- }
- databases = self.metadata.get_hbase(param)
- return databases["Result"]
|