Exemplo n.º 1
0
    def __init__(self, logger = None, dbi = None, params = None):
        """
        _init_

        Call the base class's constructor and create all necessary tables,
        constraints and inserts.
        """
        CreateAgentBase.__init__(self, logger, dbi, params)

        self.create["01wm_components"] = \
          """CREATE TABLE wm_components (
             id               INTEGER      NOT NULL,
             name             VARCHAR(255) NOT NULL,
             pid              INTEGER      NOT NULL,
             update_threshold INTEGER      NOT NULL,
             PRIMARY KEY (id),
             UNIQUE (name))"""


        for tableName in self.sequenceTables:
            seqname = '%s_SEQ' % tableName
            self.create["%s%s" % (self.seqStartNum, seqname)] = """
            CREATE SEQUENCE %s start with 1
            increment by 1 nomaxvalue cache 100""" % seqname

            triggerName = '%s_TRG' % tableName
            self.create["%s%s" % (self.seqStartNum, triggerName)] = """
                    CREATE TRIGGER %s
                        BEFORE INSERT ON %s
                        REFERENCING NEW AS newRow
                        FOR EACH ROW
                        BEGIN
                            SELECT %s.nextval INTO :newRow.id FROM dual;
                        END; """ % (triggerName, tableName, seqname)
Exemplo n.º 2
0
    def __init__(self, logger=None, dbi=None, params=None):
        """
        _init_

        Call the base class's constructor and create all necessary tables,
        constraints and inserts.
        """
        CreateAgentBase.__init__(self, logger, dbi, params)

        self.create["01wm_components"] = \
          """CREATE TABLE wm_components (
             id               INTEGER      NOT NULL,
             name             VARCHAR(255) NOT NULL,
             pid              INTEGER      NOT NULL,
             update_threshold INTEGER      NOT NULL,
             PRIMARY KEY (id),
             UNIQUE (name))"""

        for tableName in self.sequenceTables:
            seqname = '%s_SEQ' % tableName
            self.create["%s%s" % (self.seqStartNum, seqname)] = """
            CREATE SEQUENCE %s start with 1
            increment by 1 nomaxvalue cache 100""" % seqname

            triggerName = '%s_TRG' % tableName
            self.create["%s%s" % (self.seqStartNum, triggerName)] = """
                    CREATE TRIGGER %s
                        BEFORE INSERT ON %s
                        REFERENCING NEW AS newRow
                        FOR EACH ROW
                        BEGIN
                            SELECT %s.nextval INTO :newRow.id FROM dual;
                        END; """ % (triggerName, tableName, seqname)
Exemplo n.º 3
0
    def __init__(self, logger=None, dbi=None, params=None):
        """
        _init_

        Call the base class's constructor and create all necessary tables,
        constraints and inserts.
        """
        CreateAgentBase.__init__(self, logger, dbi, params)
Exemplo n.º 4
0
    def __init__(self, logger = None, dbi = None, params = None):
        """
        _init_

        Call the base class's constructor and create all necessary tables,
        constraints and inserts.
        """
        CreateAgentBase.__init__(self, logger, dbi, params)
Exemplo n.º 5
0
    def execute(self, conn = None, transaction = None):
        for i in self.create.keys():
            self.create[i] = self.create[i] + " ENGINE=InnoDB"
            self.create[i] = self.create[i].replace('INTEGER', 'INT(11)')


        return CreateAgentBase.execute(self, conn, transaction)
Exemplo n.º 6
0
    def __init__(self, logger=None, dbi=None, params=None):
        """
        _init_

        Call the base class's constructor and create all necessary tables,
        constraints and inserts.
        """
        CreateAgentBase.__init__(self, logger, dbi, params)

        self.create["02wm_workers"] = \
          """CREATE TABLE wm_workers (
             component_id  INTEGER NOT NULL REFERENCES wm_components(id),
             name          VARCHAR(255) NOT NULL,
             last_updated  INTEGER      NOT NULL,
             state         VARCHAR(255),
             pid           INTEGER,
             last_error    INTEGER,
             error_message VARCHAR(1000),
             UNIQUE (component_id, name))"""

        # constraints added in table definition
        self.constraints.clear()
Exemplo n.º 7
0
    def __init__(self, logger = None, dbi = None, params = None):
        """
        _init_

        Call the base class's constructor and create all necessary tables,
        constraints and inserts.
        """
        CreateAgentBase.__init__(self, logger, dbi, params)
             
        self.create["02wm_workers"] = \
          """CREATE TABLE wm_workers (
             component_id  INTEGER NOT NULL REFERENCES wm_components(id),
             name          VARCHAR(255) NOT NULL,
             last_updated  INTEGER      NOT NULL,
             state         VARCHAR(255),
             pid           INTEGER,
             last_error    INTEGER,
             error_message VARCHAR(1000),
             UNIQUE (component_id, name))"""
         
        # constraints added in table definition
        self.constraints.clear() 
Exemplo n.º 8
0
    def execute(self, conn=None, transaction=None):
        for i in self.create.keys():
            self.create[i] = self.create[i].replace('AUTO_INCREMENT',
                                                    'AUTOINCREMENT')

        return CreateAgentBase.execute(self, conn, transaction)
Exemplo n.º 9
0
    def execute(self, conn=None, transaction=None):
        for i in self.create.keys():
            self.create[i] += " ENGINE=InnoDB ROW_FORMAT=DYNAMIC"
            self.create[i] = self.create[i].replace('INTEGER', 'INT(11)')

        return CreateAgentBase.execute(self, conn, transaction)
Exemplo n.º 10
0
 def execute(self, conn = None, transaction = None):
     for i in self.create.keys():
         self.create[i] = self.create[i].replace('AUTO_INCREMENT', 'AUTOINCREMENT')
         
     return CreateAgentBase.execute(self, conn, transaction)