Reputation: 691
Im using Django 2.0. My task is to write a large dataset that after being analized it'll be dropped every day. I've decided to write that data in SQLite using database routers that generates the file automatically but it does not create the model table and throws an OperationalError cause the table does not exist. Which (if someone had a similar situation) should be a nice solution for this?
Thanks in advance!
Upvotes: 0
Views: 775
Reputation: 15738
Elaborating on @SuperStew suggestion, something like this should work:
# in settings.py
import os
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase',
}
}
db_path = DATABASES['default']['NAME']
if not os.path.isfile(db_path):
open(db_path, 'wb').close()
Upvotes: 1