Skip to content

Commit

Permalink
Merge pull request #31 from Clinical-Genomics/allow_demo_db
Browse files Browse the repository at this point in the history
Use memory DB as default DB
  • Loading branch information
northwestwitch authored Mar 15, 2023
2 parents 2f44f58 + cad4379 commit bb6fbbf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[unreleased]
### Fixed
- Use a memory database as default database in demo instance

[1.0.0]
### Added
- Endpoint to Ensembl genes download
Expand Down
4 changes: 2 additions & 2 deletions src/schug/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pydantic import BaseSettings

DEMO_DB: str = "sqlite://"
SCHUG_PACKAGE = Path(__file__).parent
PACKAGE_ROOT: Path = SCHUG_PACKAGE.parent
ENV_FILE: Path = PACKAGE_ROOT / ".env"
Expand All @@ -10,8 +11,7 @@
class Settings(BaseSettings):
"""Settings for serving the schug app"""

db_name: str = "database.db"
db_uri: str = "sqlite:///database.db"
db_uri: str = DEMO_DB
host: str = "localhost"
port: int = 8000

Expand Down
10 changes: 7 additions & 3 deletions src/schug/database/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from sqlmodel import create_engine, SQLModel
from schug.config import DEMO_DB, settings
from sqlmodel import SQLModel, create_engine

from schug.config import settings
DEMO_CONNECT_ARGS: dict = {"check_same_thread": False}

engine = create_engine(settings.db_uri, echo=True)
if settings.db_uri == DEMO_DB:
engine = create_engine(settings.db_uri, connect_args=DEMO_CONNECT_ARGS, echo=True)
else:
engine = create_engine(settings.db_uri, echo=True)

SQLModel.metadata.create_all(engine)

0 comments on commit bb6fbbf

Please sign in to comment.