Skip to content

Commit

Permalink
Updates database template with database check and creation
Browse files Browse the repository at this point in the history
  • Loading branch information
cicekhayri committed Dec 13, 2023
1 parent 13ffd2d commit 49f6bc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pyblaze/cli/templates/database_template.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, scoped_session, sessionmaker
from sqlalchemy_utils import database_exists, create_database


engine = create_engine("{{database_url}}")

if not database_exists(engine.url):
create_database(engine.url)

db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine)
)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies = [
"sqlalchemy",
"bcrypt",
"inflect",
"sqlalchemy-utils"
]

[project.scripts]
Expand Down

0 comments on commit 49f6bc3

Please sign in to comment.