this repo has no description

BaseFeed: add helpers for transaction begin/commit and wal_checkpoint

Changed files
+16
feeds
+16
feeds/__init__.py
···
from datetime import datetime, timezone, timedelta
class BaseFeed:
def process_commit(self, commit):
raise NotImplementedError
···
return parsed
elif parsed > utc_now:
return utc_now
···
from datetime import datetime, timezone, timedelta
class BaseFeed:
+
def __init__(self):
+
self.in_transaction = False
+
def process_commit(self, commit):
raise NotImplementedError
···
return parsed
elif parsed > utc_now:
return utc_now
+
+
def transaction_begin(self, db):
+
if not self.in_transaction:
+
db.execute('BEGIN')
+
self.in_transaction = True
+
+
def transaction_commit(self, db):
+
if self.in_transaction:
+
db.execute('COMMIT')
+
self.in_transaction = False
+
+
def wal_checkpoint(self, db, mode='PASSIVE'):
+
db.pragma(f'wal_checkpoint({mode})')