Skip to content

Conversation

max-moser
Copy link

This PR is basically the DB part of inveniosoftware/invenio-config#57 but doesn't require the settings to be set via environment variables – invenio.cfg is also fine for example.

@max-moser max-moser force-pushed the granular-connection-strings branch 2 times, most recently from 7dfb05d to 2468dfe Compare March 30, 2025 22:16
params[config_name] = app.config.get(f"DB_{config_name.upper()}", None)

if all(params.values()):
uri = f"{params['protocol']}://{params['user']}:{params['password']}@{params['host']}:{params['port']}/{params['name']}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I felt a bit uneasy looking at this and came across https://docs.sqlalchemy.org/en/20/core/engines.html#creating-urls-programmatically which might also handle some validation :)

Not a blocker, so feel free to take as out of scope and shelve.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've updated the PR to use that function, feels better to not code connection strings by hand

it seems like the protocol is the only actually required parameter for that function, should we relax the if all(params.values()) check accordingly?
personally i'm slightly leaning towards leaving it as is; i don't think laxness here will buy us a lot, and being stricter makes the opt-in stronger.

@max-moser max-moser force-pushed the granular-connection-strings branch 2 times, most recently from 7b83acd to c4db08d Compare March 31, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants