-
Notifications
You must be signed in to change notification settings - Fork 2.7k
refs #4077, removing sqlite prefix in path to db file expected by aio… #4081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,7 +415,9 @@ async def append_event(self, session: Session, event: Event) -> Event: | |
| @asynccontextmanager | ||
| async def _get_db_connection(self): | ||
| """Connects to the db and performs initial setup.""" | ||
| async with aiosqlite.connect(self._db_path) as db: | ||
| # aiosqlite requires a file path | ||
| path = self._db_path.replace("sqlite+aiosqlite:///", "") | ||
| async with aiosqlite.connect(path) as db: | ||
|
Comment on lines
+418
to
+420
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this change correctly handles the database path for To resolve this, the path stripping logic should be applied in |
||
| db.row_factory = aiosqlite.Row | ||
| await db.execute(PRAGMA_FOREIGN_KEYS) | ||
| await db.executescript(CREATE_SCHEMA_SQL) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
str.replace()for removing a prefix can be less robust than alternatives. For removing a prefix, it's more idiomatic and safer to usestr.removeprefix()(available in Python 3.9+). Given the modern Python features used elsewhere in the codebase,removeprefixis likely available and is the cleanest option.