I solved it. MongoDB can handle Binary data. Mysql can do BLOB.
Just picke.dumps() or torch.save(buffer).
This how it looks:
class TrainingData(mongoengine.Document):
    date_time = mongoengine.DateTimeField(required=True)
    epoch = mongoengine.IntField()
    train_loss = mongoengine.FloatField()
    test_loss = mongoengine.FloatField()
    train_accuracy = mongoengine.FloatField()
    test_accuracy = mongoengine.FloatField()
    gradients = mongoengine.BinaryField()