Hi all,
Does anyone have a simple solution to using (or modifying) dumpdata to trucate a simple table down to the last n lines. I like to use dump data for test fixtures but the data size has gotten so large this doesn't make sense. BTW - I didn't design the table I'm just the sucker which has to deal with it.
For those who may ask how the structure looks here it is.
From Django Side
class GridResourceUsage(models.Model):
"""Sampled point in time of license usage for individual grid resource. Includes who and quanity."""
timestamp = models.DateTimeField(db_index=True)
grid_license_resource = models.ForeignKey(GridLicResource)
total = models.IntegerField(default=None, null=True)
limit = models.IntegerField(default=None, null=True)
free = models.IntegerField(default=None, null=True)
intern = models.IntegerField(default=None, null=True)
extern = models.IntegerField(default=None, null=True)
waiting = models.IntegerField(default=None, null=True)
def __unicode__(self):
return str("GRU-" + self.grid_license_resource.name)
class Meta:
ordering = ['-timestamp']
@models.permalink
def get_absolute_url(self):
return('hist_res_id', (), {'resource': str(self.grid_license_resource.name), 'id':str(self.id)})
From MySQL side
CREATE TABLE `gridresource_gridresourceusage` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`timestamp` datetime NOT NULL,
`grid_license_resource_id` int(11) NOT NULL,
`total` int(11) DEFAULT NULL,
`limit` int(11) DEFAULT NULL,
`free` int(11) DEFAULT NULL,
`intern` int(11) DEFAULT NULL,
`extern` int(11) DEFAULT NULL,
`waiting` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `gridresource_gridresourceusage_timestamp` (`timestamp`),
KEY `gridresource_gridresourceusage_grid_license_resource_id` (`grid_license_resource_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2891167 DEFAULT CHARSET=latin1;