Skip to content

Commit

Permalink
Change default location for db and logs to ~/.caravel Fix #915 (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones authored and mistercrunch committed Aug 17, 2016
1 parent 66c2b84 commit 88f4260
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
11 changes: 5 additions & 6 deletions caravel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
from flask_appbuilder.security.manager import AUTH_DB

BASE_DIR = os.path.abspath(os.path.dirname(__file__))

DATA_DIR = os.path.join(os.path.expanduser('~'), '.caravel')
if not os.path.exists(DATA_DIR):
os.makedirs(DATA_DIR)

# ---------------------------------------------------------
# Caravel specific config
Expand All @@ -34,10 +36,7 @@
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h' # noqa

# The SQLAlchemy connection string.
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel.db'
# this is for platform specific: "nt" is for windows, "posix" is *nix (including Mac)
if os.name == "nt":
SQLALCHEMY_DATABASE_URI = 'sqlite:///c:\\tmp\\caravel.db'
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'caravel.db')
# SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
# SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'

Expand Down Expand Up @@ -172,7 +171,7 @@

ENABLE_TIME_ROTATE = False
TIME_ROTATE_LOG_LEVEL = 'DEBUG'
FILENAME = '/tmp/caravel.log'
FILENAME = os.path.join(DATA_DIR, 'caravel.log')
ROLLOVER = 'midnight'
INTERVAL = 1
BACKUP_COUNT = 30
Expand Down
6 changes: 3 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ of the parameters you can copy / paste in that configuration module: ::
# caravel metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel.db'
SQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/caravel.db'

# Flask-WTF flag for CSRF
CSRF_ENABLED = True
Expand All @@ -149,7 +149,7 @@ for more information on how to configure Caravel.

Please make sure to change:

* *SQLALCHEMY_DATABASE_URI*, by default it is stored on */tmp* and so will be cleared after each boot
* *SQLALCHEMY_DATABASE_URI*, by default it is stored at *~/.caravel/caravel.db*
* *SECRET_KEY*, to a long random string

Database dependencies
Expand Down Expand Up @@ -202,7 +202,7 @@ complies with the Flask-Cache specifications.
Flask-Cache supports multiple caching backends (Redis, Memcached,
SimpleCache (in-memory), or the local filesystem). If you are going to use
Memcached please use the pylibmc client library as python-memcached does
not handle storing binary data correctly. If you use Redis, please install
not handle storing binary data correctly. If you use Redis, please install
[python-redis](https://pypi.python.org/pypi/redis).

For setting your timeouts, this is done in the Caravel metadata and goes
Expand Down
3 changes: 1 addition & 2 deletions tests/caravel_test_config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from caravel.config import *

AUTH_USER_REGISTRATION_ROLE = 'alpha'
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel_unittests.db'
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'unittests.db')
DEBUG = True
CARAVEL_WEBSERVER_PORT = 8081

# Allowing SQLALCHEMY_DATABASE_URI to be defined as an env var for
# continuous integration
if 'CARAVEL__SQLALCHEMY_DATABASE_URI' in os.environ:
SQLALCHEMY_DATABASE_URI = os.environ.get('CARAVEL__SQLALCHEMY_DATABASE_URI')

0 comments on commit 88f4260

Please sign in to comment.