Skip to content

Commit

Permalink
função [config_database_path] para confiurar o diretorio onde sera ar…
Browse files Browse the repository at this point in the history
…mazenado o banco de dados
  • Loading branch information
thisiscleverson committed Feb 12, 2024
1 parent 9ede43f commit 10ee979
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import os
from flask import Flask, render_template
from flask_migrate import Migrate
from flask_session import Session

from .models import config_models

db_dir = '/.database'


def config_database_path(db_dir):
path_dir = os.path.expanduser('~') + db_dir
os.makedirs(path_dir, exist_ok=True)
return os.path.join(path_dir, 'blog.db')


def create_register_blueprint(app):
from .auth import auth
Expand Down Expand Up @@ -31,7 +40,7 @@ def create_app():
static_folder='../static'
)

app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db"
app.config["SQLALCHEMY_DATABASE_URI"] = f'sqlite:///{config_database_path(db_dir)}'
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"

Expand Down

0 comments on commit 10ee979

Please sign in to comment.