Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Jan 21, 2016
1 parent 9319905 commit b7097df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 17 additions & 1 deletion PyHardLinkBackup/backup_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,28 @@
from django.db import models
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.db.backends.signals import connection_created

from PyHardLinkBackup.phlb.config import phlb_config

log = logging.getLogger("phlb.%s" % __name__)


def setup_sqlite(sender, connection, **kwargs):
if connection.vendor == 'sqlite':
cursor = connection.cursor()
pragmas = (
"PRAGMA temp_store = MEMORY;",
"PRAGMA synchronous = OFF;"
)
for pragma in pragmas:
log.info("Execute: '%s'" % pragma)
print("Execute: '%s'" % pragma)
cursor.execute(pragma)

connection_created.connect(setup_sqlite)


class BackupRun(models.Model):
"""
One Backup run prefix: start time + backup name
Expand Down Expand Up @@ -120,4 +136,4 @@ def __str__(self):

class Meta:
ordering = ["-backup_run__backup_datetime"]
get_latest_by = "-backup_run__backup_datetime"
get_latest_by = "-backup_run__backup_datetime"
3 changes: 2 additions & 1 deletion PyHardLinkBackup/django_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
}
print("Use Database file: '%s'" % DATABASES["default"]["NAME"])

AUTOCOMMIT = False

# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
Expand Down Expand Up @@ -146,4 +147,4 @@
'level': _phlb_config.logging_level,
},
},
}
}

0 comments on commit b7097df

Please sign in to comment.