Skip to content

Commit 0df33b0

Browse files
authored
Add sqlite connector support (#733)
Configurable choice to setup the sqlalchemy engine with SQLite rather than PostgreSQL. This is set in the security configuration. The database name in the database credentials file should be the path to the SQLite database.
1 parent e5448b9 commit 0df33b0

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

src/murfey/server/murfey_db.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def url(security_config: Security | None = None) -> str:
1515
security_config = security_config or get_security_config()
1616
with open(security_config.murfey_db_credentials, "r") as stream:
1717
creds = yaml.safe_load(stream)
18+
if security_config.db == "sqlite":
19+
return f"sqlite:///{creds['database']}"
1820
f = Fernet(security_config.crypto_key.encode("ascii"))
1921
p = f.decrypt(creds["password"].encode("ascii"))
2022
return f"postgresql+psycopg2://{creds['username']}:{p.decode()}@{creds['host']}:{creds['port']}/{creds['database']}"

src/murfey/util/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class Security(BaseModel):
228228
# Murfey database settings
229229
murfey_db_credentials: Path
230230
crypto_key: str
231+
db: str = "postgres"
231232
sqlalchemy_pooling: bool = True
232233

233234
# ISPyB settings

0 commit comments

Comments
 (0)