Example #1
0
 def alterAddColumn(self, db, table, default):
     try:
         if table in self.Tabs:
             self.Tabs[table].countCol += 1
             if os.path.exists("data/databases/" + str(db) + "/" +
                               str(table)):
                 contenido = os.listdir("data/databases/" + str(db) + "/" +
                                        str(table))
                 contenido.remove('indx.b')
                 for x in range(0, 30):
                     var = 'CS' + str(x) + '.b'
                     if var in contenido:
                         indx = bi.read("data/databases/" + str(db) + "/" +
                                        str(table) + "/CS" + str(x) + ".b")
                         v = Registro(indx.valores)
                         v.alterAddColumn()
                         sobre = bi.write(
                             v, "data/databases/" + str(db) + "/" +
                             str(table) + "/CS" + str(x) + ".b")
                 self.Tabs[table].tuplas.refreshMem()
                 self.grabar(db)
                 return 0
         else:
             return 3
     except:
         return 1
Example #2
0
 def writeI(self):
     data=[]
     for x in self.indx:
         if x != None:
             data.append(x.nombre)
         else:
             data.append(None)
     data.append(self.pkey)
     bin.write(data, self.ruta+"/indx.b")
Example #3
0
 def insert(self, registro):
     val = []
     try:
         for key in self.pkey:
             val.append(registro[key])
         i = self.hash(val[0])
         if self.indx[i] == None:
             self.indx[i] = Cilindro("CS" + str(i), self.pkey, i, self.ruta)
             bin.write([None] * 30, self.ruta + "/" + "CS" + str(i) + ".b")
             self.writeI()
         return self.indx[i].insert(registro)
     except:
         return 1
Example #4
0
 def readI(self):
     if os.path.exists(self.ruta+"/indx.b"):
         data = bin.read(self.ruta+"/indx.b")
         i = 0
         if type(data[-1]) is list: self.pkey = data[-1]
         for d in data:
             if type(d) is str:
                 self.indx[i] = Cilindro(d, self.pkey, i, self.ruta)
             elif d is None:
                 self.indx[i] = None
             i+=1
Example #5
0
 def grabar(self, ruta):
     if os.path.exists('data/databases/' + str(ruta)):
         bi.write(self.Tabs, 'data/databases/' + str(ruta) + "/tab.b")
Example #6
0
 def load(self, ruta):
     if os.path.isfile('data/databases/' + str(ruta) + "/tab.b"):
         self.Tabs = bi.read('data/databases/' + str(ruta) + "/tab.b")
Example #7
0
    def refreshMem(self):
        for x in self.indx:
            if x != None:
                x.indx = bin.read(self.ruta +"/"+ x.nombre + ".b")
		        x.pkeys = self.pkey
Example #8
0
 def readD(self):
     if os.path.exists(self.ruta):
         self.indx = bi.read(self.ruta)
Example #9
0
 def writeD(self):
     bi.write(self.indx, self.ruta)
Example #10
0
 def writer(self):
     b.write(self.arr,"data/databases/Bases.b")
Example #11
0
 def load(self):
     if os.path.exists("data/databases/Bases.b"):
         var=b.read("data/databases/Bases.b")
         for i in var:
             self.add(i)