本文整理汇总了Python中utils.Utils.insert_table方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.insert_table方法的具体用法?Python Utils.insert_table怎么用?Python Utils.insert_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Utils
的用法示例。
在下文中一共展示了Utils.insert_table方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import insert_table [as 别名]
def get(self, id):
(project, dataset, table) = Utils.parse_bqid(id)
query = DELETE_QUERY % (dataset, table)
response = Utils.get_bq().tables().delete(projectId=project, datasetId=dataset, tableId=table).execute()
TABLE_CACHE.clear()
Utils.insert_table(dataset, table)
TABLE_CACHE.clear()
args = {}
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps(args))
示例2: main
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import insert_table [as 别名]
def main():
if config.MODE not in ['gnip', 'twitter']:
print "Invalid mode: %s" % config.MODE
exit()
logger = Utils.enable_logging()
print "Running in mode: %s" % config.MODE
schema_file = None
if config.MODE == 'gnip':
schema_file = "./schema/schema_gnip.json"
else:
schema_file = "./schema/schema_twitter.json"
schema_str = Utils.read_file(schema_file)
schema = json.loads(schema_str)
Utils.insert_table(config.DATASET_ID, config.TABLE_ID, schema)
print "Default table: %s.%s" % (config.DATASET_ID, config.TABLE_ID)
if config.MODE == 'gnip':
GnipListener.start(schema, logger)
elif config.MODE == 'twitter':
TwitterListener.start(schema, logger)
示例3: get
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import insert_table [as 别名]
def get(self):
response = []
type = self.request.get("type")
dataset = self.request.get("dataset")
if "gnip" in dataset:
dataset = "gnip"
schema_file = "./schema/schema_gnip.json"
else:
dataset = "twitter"
schema_file = "./schema/schema_twitter.json"
table = self.request.get("name")
rule_list = self.request.get("rules")
imprt = self.request.get("import")
schema_str = Utils.read_file(schema_file)
schema = json.loads(schema_str)
Utils.insert_table(dataset, table, schema)
TABLE_CACHE.clear()
name = Utils.make_tag(dataset, table)
rule_list = [s.strip() for s in rule_list.splitlines()]
for r in rule_list:
params = GNIP_RULES_PARAMS
params['tag'] = name
response.append(rules.add_rule(r, **params))
TABLE_CACHE.clear()
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps(response))
示例4: on_data
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import insert_table [as 别名]
def on_data(self, data):
# get bulk records, but process individually based on tag-based routing
records_str = data.strip().split(NEWLINE)
for r in records_str:
record = json.loads(r)
if not record.get('delete', None):
tags = self.get_table_tags(record)
if not tags:
tags = [self.default_table]
# process multiple tags on a record
for tag in tags:
table = None
if not tag:
table = self.default_table
else:
table = self.table_mapping.get(tag, None)
if not table:
table = tag.split(".")
created = Utils.insert_table(table[0], table[1], self.schema)
# Brand new table
if created and created != True:
self.logger.info('Created BQ table: %s' % tag)
self.table_mapping[tag] = table
record_scrubbed = Utils.scrub(record)
Utils.insert_records(table[0], table[1], [record_scrubbed])
if self.logger:
self.logger.info('@%s: %s (%s)' % (record['actor']['preferredUsername'], record['body'].encode('ascii', 'ignore'), tags))
self.count = self.count + 1
return True