def purge_trans(options):
days_opt = options['days']
days_default = False
if days_opt == -1:
days_opt = 0
days_default = True
t = Transmission.objects.filter(start_datetime__lt=datetime.now() - timedelta(days=days_opt))
print('Pruning %s transmissions older than %s days.' % (t.count(), days_opt))
t.delete()
print('Pruning complete')
if 'sqlite' in db_engine:
def vacuum_db(using='default'):
cursor = connections[using].cursor()
cursor.execute("VACUUM")
transaction.commit()
print ("Vacuuming database...")
before = os.stat(db_name).st_size
print ("Size before: %s bytes" % before)
vacuum_db()
after = os.stat(db_name).st_size
print ("Size after: %s bytes" % after)
print ("Reclaimed: %s bytes" % (before - after))
评论列表
文章目录