When developing it makes sense to have the database file in the local repository directory, to have a dev.env which is valid for all developers it needs to be relative..
I have been doing hacks in settings.py to get around it for a few years now but I would like a discussion about how to maybe integrate such a feature into django-environ.
This basically just assumes that if the the file is at the root of the system it's instead relative but I'm looking for a way to get rid of these in every project..
for db in DATABASES:
if DATABASES[db]['ENGINE'] == 'django.db.backends.sqlite3':
if os.path.split(DATABASES[db]['NAME'])[0] == "/":
DATABASES[db]['NAME'] = root(DATABASES[db]['NAME'][1:])
I am thinking that this is kind of sane because no one proably stores the database in the root of the file system but making it optional by having a sqlite_root argument to the db-url function maybe works?
root = environ.Path(__file__) - 2
...
DATABASES = {
'default': env.db(sqlite_root=root()),
}
I think that both relative AND absolute paths should work.
One option which I think might work safely for triggering a relative path instead of absolute is to do it when host is . or some other reserved name which isn't really a hostname. It should error out if sqlite_root was not provided to the url parse function.
DATABASE_URL=sqlite://./db.sqlite3
Please share your opinions on this..
When developing it makes sense to have the database file in the local repository directory, to have a
dev.envwhich is valid for all developers it needs to be relative..I have been doing hacks in settings.py to get around it for a few years now but I would like a discussion about how to maybe integrate such a feature into django-environ.
This basically just assumes that if the the file is at the root of the system it's instead relative but I'm looking for a way to get rid of these in every project..
I am thinking that this is kind of sane because no one proably stores the database in the root of the file system but making it optional by having a
sqlite_rootargument to the db-url function maybe works?I think that both relative AND absolute paths should work.
One option which I think might work safely for triggering a relative path instead of absolute is to do it when host is
.or some other reserved name which isn't really a hostname. It should error out ifsqlite_rootwas not provided to the url parse function.Please share your opinions on this..