Skip to content

Commit

Permalink
ability to get single account by name
Browse files Browse the repository at this point in the history
  • Loading branch information
vladkens committed Jan 5, 2024
1 parent ae2b15d commit 490ffe2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions twscrape/accounts_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ async def get_all(self):
rs = await fetchall(self._db_file, qs)
return [Account.from_rs(x) for x in rs]

async def get_account(self, username: str):
qs = "SELECT * FROM accounts WHERE username = :username"
rs = await fetchone(self._db_file, qs, {"username": username})
if not rs:
return None
return Account.from_rs(rs)

async def save(self, account: Account):
data = account.to_rs()
cols = list(data.keys())
Expand Down

0 comments on commit 490ffe2

Please sign in to comment.