Skip to content

Commit

Permalink
refactor: rename ClientStore.conn to _conn
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Mar 11, 2024
1 parent 6e879a8 commit 7d6686c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/dumdum/client/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

class ClientStore:
def __init__(self, conn: SQLiteConnection) -> None:
self.conn = conn
self._conn = conn

@contextlib.contextmanager
def transaction(self) -> Iterator[Self]:
with self.conn.transaction():
with self._conn.transaction():
yield self

def get_last_selected_channel(
self,
addr: str,
default: str | T = None,
) -> str | T:
ret = self.conn.fetchval(
ret = self._conn.fetchval(
"SELECT channel_name FROM last_selected_channel WHERE addr = ?",
addr,
)
Expand All @@ -32,21 +32,21 @@ def get_last_selected_channel(
def set_last_selected_channel(
self, addr: str, channel_name: str | None = None
) -> None:
self.conn.execute(
self._conn.execute(
"INSERT INTO last_selected_channel (addr, channel_name) VALUES (?1, ?2) "
"ON CONFLICT (addr) DO UPDATE SET channel_name = ?2",
addr,
channel_name,
)

def get_setting(self, name: str, default: Any = None) -> Any:
row = self.conn.fetchone("SELECT value FROM setting WHERE name = ?", name)
row = self._conn.fetchone("SELECT value FROM setting WHERE name = ?", name)
if row is None:
return default
return row[0]

def set_setting(self, name: str, value: Any) -> None:
self.conn.execute(
self._conn.execute(
"INSERT INTO setting (name, value) VALUES (?1, ?2) "
"ON CONFLICT (name) DO UPDATE SET value = ?2",
name,
Expand Down

0 comments on commit 7d6686c

Please sign in to comment.