mirror of
https://github.com/maubot/rss.git
synced 2025-01-25 23:16:08 -05:00
parent
b9bc6fbc81
commit
35f2fe63df
22
rss/db.py
22
rss/db.py
@ -23,7 +23,7 @@ from attr import dataclass
|
|||||||
import attr
|
import attr
|
||||||
|
|
||||||
from mautrix.types import RoomID, UserID
|
from mautrix.types import RoomID, UserID
|
||||||
from mautrix.util.async_db import Database, Scheme
|
from mautrix.util.async_db import Database, Scheme, SQLiteCursor
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -182,9 +182,23 @@ class DBManager:
|
|||||||
"INSERT INTO feed (url, title, subtitle, link, next_retry) "
|
"INSERT INTO feed (url, title, subtitle, link, next_retry) "
|
||||||
"VALUES ($1, $2, $3, $4, $5) RETURNING (id)"
|
"VALUES ($1, $2, $3, $4, $5) RETURNING (id)"
|
||||||
)
|
)
|
||||||
info.id = await self.db.fetchval(
|
# SQLite only gained RETURNING support in v3.35 (2021-03-12)
|
||||||
q, info.url, info.title, info.subtitle, info.link, info.next_retry
|
# TODO remove this special case in a couple of years
|
||||||
)
|
if self.db.scheme == Scheme.SQLITE:
|
||||||
|
cur = await self.db.execute(
|
||||||
|
q.replace(" RETURNING (id)", ""),
|
||||||
|
info.url,
|
||||||
|
info.title,
|
||||||
|
info.subtitle,
|
||||||
|
info.link,
|
||||||
|
info.next_retry,
|
||||||
|
)
|
||||||
|
assert isinstance(cur, SQLiteCursor)
|
||||||
|
info.id = cur.lastrowid
|
||||||
|
else:
|
||||||
|
info.id = await self.db.fetchval(
|
||||||
|
q, info.url, info.title, info.subtitle, info.link, info.next_retry
|
||||||
|
)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
async def set_backoff(self, info: Feed, error_count: int, next_retry: int) -> None:
|
async def set_backoff(self, info: Feed, error_count: int, next_retry: int) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user