Skip to content

Commit

Permalink
SqEntryList: rename filename to database
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 7, 2024
1 parent c94a094 commit f33fb4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _newInMemorySqEntryList(self) -> SqEntryList:
return SqEntryList(
entryToRaw=self._entryToRaw,
entryFromRaw=self._entryFromRaw,
filename="file::memory:", # or "file::memory:?cache=shared"
database="file::memory:", # or "file::memory:?cache=shared"
create=True,
)

Expand Down Expand Up @@ -975,7 +975,7 @@ def _switchToSQLite(
self._data = SqEntryList( # pyright: ignore[reportAttributeAccessIssue]
entryToRaw=self._entryToRaw,
entryFromRaw=self._entryFromRaw,
filename=sq_fpath,
database=sq_fpath,
create=True,
)
self._cleanupPathList.add(sq_fpath)
Expand Down
10 changes: 5 additions & 5 deletions pyglossary/sq_entry_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ def __init__( # noqa: PLR0913
self,
entryToRaw: Callable[[EntryType], RawEntryType],
entryFromRaw: Callable[[RawEntryType], EntryType],
filename: str,
database: str,
create: bool = True,
) -> None:
"""sqliteSortKey[i] == (name, type, valueFunc)."""
import sqlite3

self._entryToRaw = entryToRaw
self._entryFromRaw = entryFromRaw
self._filename = filename
self._database = database

self._con: sqlite3.Connection | None = sqlite3.connect(filename)
self._con: sqlite3.Connection | None = sqlite3.connect(database)
self._cur: sqlite3.Cursor | None = self._con.cursor()

if not filename:
raise ValueError(f"invalid {filename=}")
if not database:
raise ValueError(f"invalid {database=}")

self._orderBy = "rowid"
self._sorted = False
Expand Down

0 comments on commit f33fb4a

Please sign in to comment.