From 490ffe2620e0405c76b6a5a736db8f155a2a1ded Mon Sep 17 00:00:00 2001 From: Vlad Pronsky Date: Fri, 5 Jan 2024 19:02:33 +0200 Subject: [PATCH] ability to get single account by name --- twscrape/accounts_pool.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/twscrape/accounts_pool.py b/twscrape/accounts_pool.py index ac176fd..24d46b1 100644 --- a/twscrape/accounts_pool.py +++ b/twscrape/accounts_pool.py @@ -121,6 +121,13 @@ class AccountsPool: 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())