本文整理汇总了Python中Filter.Filter.sql方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.sql方法的具体用法?Python Filter.sql怎么用?Python Filter.sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter.Filter
的用法示例。
在下文中一共展示了Filter.sql方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tool
# 需要导入模块: from Filter import Filter [as 别名]
# 或者: from Filter.Filter import sql [as 别名]
#.........这里部分代码省略.........
self.fil = Filter(daterange = daterange,
user = user,
server = server,
search_string = search_string,
query_type = query_type,
negate = self.negate.value)
def refresh(self):
"""
Regenerate the graphs/top query lists without changing the table that
the tool pulls from
"""
# Get the status of GUI elements
self.get_new_filter()
# Don't repeat the query if self.filter hasn't changed since the last
# update
if self.fil != self.last_used_fil:
self.create_new_temp_table()
self.create_new_graphs_and_topqueries()
elif self.last_grouped_by != self.time_division_radiogroup.value:
self.create_new_graphs_and_topqueries()
def create_new_temp_table(self):
# Create a temp table
lasttable = self.current_table_name()
nexttable = self.next_table_name()
# Create main table
self.cur.execute("DROP TABLE IF EXISTS {0}".format(nexttable))
print_and_execute("CREATE TEMPORARY TABLE {0} AS {1}".format(nexttable,
self.fil.sql(lasttable)),
self.cur)
print_and_execute("ALTER TABLE {0} ADD INDEX (userid)".format(nexttable), self.cur)
print_and_execute("ALTER TABLE {0} ADD INDEX (serverid)".format(nexttable), self.cur)
self.last_used_fil = self.fil
def create_new_graphs_and_topqueries(self):
prefix = config.get('plot_dir') or 'plots'
current_dir = os.getcwd()
# Get profiles of the created table
nexttable = self.next_table_name()
profiles = query_profile(nexttable,
config.get("numtop") or 200,
self.time_division_radiogroup.value,
self.cur)
peruser_divided, peruser_alltime, full_divided, full_alltime, full_topqueries, peruser_topqueries = profiles
# Remove previous plotted data
if os.path.exists(prefix):
os.system("rm -r {0}".format(prefix))
os.mkdir(prefix)
os.chdir(prefix)
gnuplot(profiles, time_axis_label=self.time_division_radiogroup.value)
# use a for loop so that gnuplot settings don't stick around between scripts
os.system("for x in *.gnu; do gnuplot $x; done")
# Load the new image lists
self.full_ = [Image(file=x) for x in glob('full_*.png')]
self.peruser_alltime_ = [Image(file=x) for x in \
glob('peruser_alltime_*.png')]