def startCheck(self, key, lTable, tableList):
 
        clt = cyr_load_table.cyr_load_table()
       ### for Server-functions set the td-object
        
        # first - the infotable cuon must be setup
        #print 'User:'******'Database.createCuon', self.dicUser)

        # now check the rest
        
        for i in lTable:
            print 'tableDefinition = ' ,key,i
            table = clt.getTableDefinition(key,i)
            print '1---clt.savetable', table.getName()
            clt.saveTable(i,table )
            print '1+++++++++++++++++++++++++++++++++++++++++++++++++++'
            
            print '2---dbcheck', table.getName()
            self.dbcheck(table)
            print '2+++++++++++++++++++++++++++++++++++++++++++++++++++'
            
            print '3---List of tables', `tableList`
            tableList.append(table.getName())
            print '3--------------------------------------------------------------------------------------'
        return tableList
   def on_dbcheck1_activate(self, event):
       
     
       clt = cyr_load_table.cyr_load_table()
       ### for Server-functions set the td-object
       #clt.td = self.td
       tableList = []
       for key in self.nameOfXmlTableFiles.keys():
           print  "start check for : " + `key`
 
           lTable = clt.getListOfTableNames(self.nameOfXmlTableFiles[key])
           tableList = self.startCheck(key,lTable, tableList)
           print 'check finished - now create sequences'
           # Sequences !!
           lSequences = clt.getListOfSequenceNames(key)
           print 'Sequences'
           print `lSequences`
           
           # Sequences per client
           liClients = self.rpc.callRP('Database.getListOfClients', self.dicUser)
           print `liClients`
           for cli in liClients:
               for s in range(len(lSequences)):
                   seq = lSequences[s]
                   print 'seq 1 ' + seq
                   seq = seq + '_client_' + `cli`
                   lSequences[s] = seq
                   print 'seq 2 ' + seq
           print `lSequences`        
           self.startCheckSequences(key,lSequences)
          
       print 'allTables = '
       print tableList    
   def on_dbcheck1_activate(self, event):
       t1 = time.mktime(time.localtime())
       self.iPB = 1
       clt = cyr_load_table.cyr_load_table()
       ### for Server-functions set the td-object
       clt.td = self.td
       tableList = []
       for key in self.td.nameOfXmlTableFiles.keys():
           print  "start check for : " + `key`
 
           lTable = clt.getListOfTableNames(key)
           tableList = self.startCheck(key,lTable, tableList)
           print 'check finished - now create sequences'
           # Sequences !!
           lSequences = clt.getListOfSequenceNames(key)
           print 'Sequences'
           print `lSequences`
           
           # Sequences per client
           liClients = self.rpc.callRP('Database.getListOfClients', self.dicUser)
           print `liClients`
           for cli in liClients:
               for s in range(len(lSequences)):
                   seq = lSequences[s]
                   print 'seq 1 ' + seq
                   seq = seq + '_client_' + `cli`
                   lSequences[s] = seq
                   print 'seq 2 ' + seq
           print `lSequences`        
           self.startCheckSequences(key,lSequences)
          
       print 'allTables = '
       print tableList    
       self.rpc.callRP('Database.saveInfo', 'allTables', self.doEncode(repr(cPickle.dumps(tableList) )))
       print "dbcheck need : ",  ` time.mktime(time.localtime()) -t1`
Exemple #4
0
    def startCheckForeignKey(self, key, liForeign):
        print 'start check Foreign'
        clt = cyr_load_table.cyr_load_table()
       ### for Server-functions set the td-object
        clt.td = self.td
 
        for i in liForeign:
            print 'Check this Foreign key = ' , `i`
            dicForeign = clt.getForeignKeyDefinition(key, i)
            # alter table partner ADD CONSTRAINT "f_address" foreign key (addressid) references address (id) on delete restrict on update restrict ;

            sSql = 'alter table ' + dicForeign['table']
            sSql += ' ADD CONSTRAINT "f_' + dicForeign['name'] +'" '
            sSql += dicForeign['sql']
            
            self.out( sSql)
            print 'Sql Sequence = ', sSql
            result = self.rpc.callRP('Database.executeNormalQuery', sSql, self.dicUser)
    def startCheckSequences(self, key, lSequences):
        print 'start check Sequences'
        clt = cyr_load_table.cyr_load_table()
       ### for Server-functions set the td-object
       
 
        for i in lSequences:
            print 'Check this Sequence = ' , `i`
            ok =  self.rpc.callRP('Database.checkExistSequence',i, self.dicUser)
            if ok == 0:
                print 'create Sequence'
                iSeq = i.upper().find('_CLIENT_')
                if iSeq > 0:
                    seqname =i[0:iSeq]
                else:
                    seqname = i
                dicSeq = clt.getSequenceDefinition(key, seqname)
                print dicSeq
                sSql = "create sequence " + i
                if dicSeq['increment']:
                    sSql = sSql + ' INCREMENT ' + dicSeq['increment']
                if dicSeq['minvalue']:
                    sSql = sSql + ' MINVALUE ' + dicSeq['minvalue']
                if dicSeq['maxvalue']:
                    sSql = sSql + ' MAXVALUE ' + dicSeq['maxvalue']
                if dicSeq['start']:
                    sSql = sSql + ' START ' + dicSeq['start']
                if dicSeq['cache'] != '0':
                    sSql = sSql + ' CACHE ' + dicSeq['cache']
                if dicSeq['cycle'] == 'Yes':
                    sSql = sSql + ' CYCLE ' 


                    
                self.out( sSql)
                print 'Sql Sequence = ', sSql
                result = self.rpc.callRP('Database.executeNormalQuery', sSql, self.dicUser)
 def saveTable(self):
     clt = cyr_load_table()
     self.table = clt.getTableDefinition(self.xmlTableDef, self.sNameOfTable)
     clt.saveTable(self.sNameOfTable, self.table)