-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcache_data.py
46 lines (32 loc) · 1.79 KB
/
cache_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import optparse
from functools import partial
import sqlprocessor as sp
from db import getDbConnection
from tkinter_util import *
class CacheDataCommandPane(tk.Frame):
def __init__(self, parent, dbPane):
tk.Frame.__init__(self, parent)
self.dbPane = dbPane
self.processFrame = add_label_frame(parent, "Cache Data Generation/Refresh", 400, 100)
add_buttons(self.processFrame,
data=[["RFMO csv cache", partial(self.process, 4), "blue", "Generate/Refresh RFMO csv cache"]],
row=0, column=0, direction="horizontal")
parent.add(self.processFrame)
for child in self.processFrame.winfo_children(): child.grid_configure(padx=5, pady=5)
def process(self, entity_layer_id):
if not self.dbPane.isConnectionTestedSuccessfully():
popup_message("Connection not yet tested",
"The DB Connection has not been tested successfully.\n" +
"Once the DB Connection has been tested successfully, you can click the Process button again.")
return
dbOpts = self.dbPane.getDbOptions()
dbSession = getDbConnection(optparse.Values(dbOpts)).getSession()
dbSession.execute("SELECT * FROM web_cache.maintain_catch_csv_partition(%s)" % entity_layer_id)
dbOpts['sqlfile'] = "sql/populate_catch_data_in_csv.sql"
dbOpts['sqlcmd'] = "select format('vacuum analyze web_cache.%s', table_name) from schema_v('web_cache') where table_name not like 'TOTAL%'"
dbOpts['threads'] = 1
sp.process(optparse.Values(dbOpts))
# ===============================================================================================
# ----- MAIN
if __name__ == "__main__":
Application("Cache Data Generator", CacheDataCommandPane).run()