Example #1
0
    def create_table (self):

        """
        Creates the table in the database for the entity if and only if the
        table does not already exist.

        NOTE:   This method is used by the tools script for creating the
        entity tables.
        """
        
        if table_exists(self):
            logging.warning('Entity Table %s already exists in database' % (
                self.table
            ))
            return
        
        logging.info('Creating Entity Table %s' % (self.table))

        sql = """CREATE TABLE IF NOT EXISTS %s (
            added_id int auto_increment not null,
            id binary(16) not null,
            data mediumblob not null,
            create_date int not null,
            update_date int not null,
            PRIMARY KEY(added_id),
            UNIQUE(id)
        ) CHARSET=utf8 COLLATE=utf8_unicode_ci ENGINE=InnoDB""" % (
            self.table
        )
        self.db.execute(sql)
Example #2
0
    def create_table (self):

        """
        Creates the table in the database for this index if and only if the
        table does not already exist.

        NOTE: This method is used by the tools script for creating the
        tables for indexes.
        """
        
        if table_exists(self):
            logging.warning('Index Table %s already exists in database' % (
                self.table
            ))
            return
        
        logging.info('Creating Index Table %s' % (self.table))

        property_type = 'varchar(255)'
        if self.relationship:
            property_type = 'binary(16)'

        sql = """CREATE TABLE IF NOT EXISTS %s (
            %s binary(16) not null,
            %s %s not null,
            datetime int not null,
            PRIMARY KEY (%s,%s)
        ) CHARSET=utf8 COLLATE=utf8_unicode_ci ENGINE=InnoDB""" % (
            self.table,
            self.entity_key_id,
            self.property,
            property_type,
            self.entity_key_id,
            self.property
        )
        
        self.db.execute(sql)