def __init__(self, file_or_filepath): # Note: we keep self.db around to avoid the db getting GC'd if hasattr(file_or_filepath, 'mode'): self.db = Mk4py.storage(file_or_filepath) else: self.db = Mk4py.storage(file_or_filepath, 0) dirs = self.db.view('dirs') self.table = dirs[0].files[0]._B
def __init__(self): # open the IDA Sync database, creating it if it doesn't exist. self.db = mk.storage("databases/ida_sync.db", 1) # if it doesn't already exist, define a view to track user updates. description = "__last__[username:S,project:S,timestamp:L]" self.last_view = self.db.getas(description)
def setUpViews(self): self.s = s = Mk4py.storage() self.v0 = s.getas('v0[s:S,i:I]') self.v1 = s.getas('v1[s:S,f:D]') self.v2 = s.getas('v2[i:I,b:M]') for vals in [('a',1),('b',2),('c',3)]: self.v0.append(vals) for vals in [('c',1.0),('b',2.0),('a',3.0)]: self.v1.append(vals) for vals in [(2,'\2'),(3,'\3'),(4,'\4')]: self.v2.append(vals) t = self.v1.rename('s', 't') self.p0 = t.product(self.v0) self.g0 = self.p0.groupby(self.p0.t, self.p0.f, 'details') self.f0 = self.g0.flatten(self.g0.details) self.f1 = self.f0[3:] self.m0 = self.f1.copy() def f(row): row.i = row.i + 1 self.m0.map(f)
def setUpViews(self): self.s = s = Mk4py.storage() self.v0 = s.getas('v0[s:S,i:I]') self.v1 = s.getas('v1[s:S,f:D]') self.v2 = s.getas('v2[i:I,b:M]') for vals in [('a', 1), ('b', 2), ('c', 3)]: self.v0.append(vals) for vals in [('c', 1.0), ('b', 2.0), ('a', 3.0)]: self.v1.append(vals) for vals in [(2, '\2'), (3, '\3'), (4, '\4')]: self.v2.append(vals) t = self.v1.rename('s', 't') self.p0 = t.product(self.v0) self.g0 = self.p0.groupby(self.p0.t, self.p0.f, 'details') self.f0 = self.g0.flatten(self.g0.details) self.f1 = self.f0[3:] self.m0 = self.f1.copy() def f(row): row.i = row.i + 1 self.m0.map(f)
def setUpView(self): self.s = s = Mk4py.storage() self.v = v = s.getas('test[i:I,l:L,f:F,d:D,s:S,v[s:S],b:B,m:M]') v.append()
for file in os.listdir("modules"): if (file.endswith(".py")): file = file.split(".")[0] exec("from " + file + " import *") try: module = sys.argv[1] cmd = sys.argv[2] if (cmd == "create" or cmd == "drop" or cmd == "dump"): project = sys.argv[3] except: print "usage: dbs <module> [list] [<create|drop|dump> <proj>]" sys.exit(1) db = mk.storage("databases/" + module + ".db", 1) ### LIST ############################################################################################################### if (cmd == "list"): print "views:", for table in db.contents().properties(): if (table.startswith("__") and table.endswith("__")): continue print table, #view = db.view(table) #for struct in view.structure(): # print "\t", # print struct
def __init__(self): # open the users database, creating it if it doesn't exist. self.db = mk.storage("databases/users.db", 1) # define the user table (view) if it doesn't already exist. self.view = self.db.getas("users[username:S,password:S,realname:S]")