Example #1
0
 def drop_functions(self):
     """DROP all related functions
     """
     res = 0
     for sql in self.sql_drop_functions():
         res = res + dbcommands.execute_raw(sql)
     return res
Example #2
0
 def drop_triggers(self, name):
     """DROP related triggers
     """
     res = 0
     for sql in self.sql_drop_triggers(name):
         res = res + dbcommands.execute_raw(sql, self.database)
     return res
Example #3
0
 def initialize(self):
     """Initialize the agregate table with values from source table
     May be long on huge tables
     """
     sql = self.sql_init()
     res = dbcommands.execute_raw(sql, database=self.database)
     return res
Example #4
0
 def create_functions(self):
     """Create all functions in the database
     """
     res = 0
     for sql in self.sql_create_functions():
         if res == 0:
             res = dbcommands.execute_raw(sql, self.database)
     return res
Example #5
0
 def create_trigger(self, sql):
     """Create a trigger
     """
     if self.verbose > 2:
         stm = dbcommands.mogrify(sql, database=self.database)
         sys.stdout.write(stm)
     res = dbcommands.execute_raw(sql, self.database)
     return res
Example #6
0
    def create_table(self):
        """
        table (string)
        column (string)
        aggregats (array)

        Return :
        - 0 is case of creation + success
        - 1 if table already exists
        """
        if not self.agg_table_ispresent():
            sql = self.sql_create_table()
            return dbcommands.execute_raw(sql, self.database)
        else:
            return 1
Example #7
0
 def drop_table(self):
     sql = self.sql_drop_table()
     return dbcommands.execute_raw(sql)