MCPcopy
hub / github.com/chidiwilliams/buzz / insert

Method insert

buzz/db/dao/dao.py:20–35  ·  view source on GitHub ↗
(self, record: T)

Source from the content-addressed store, hash-verified

18 self.table = table
19
20 def insert(self, record: T):
21 query = self._create_query()
22 fields = [
23 field for field in record.__dict__.keys() if field not in self.ignore_fields
24 ]
25 query.prepare(
26 f"""
27 INSERT INTO {self.table} ({", ".join(fields)})
28 VALUES ({", ".join([f":{key}" for key in fields])})
29 """
30 )
31 for field in fields:
32 query.bindValue(f":{field}", getattr(record, field))
33
34 if not query.exec():
35 raise Exception(query.lastError().text())
36
37 def find_by_id(self, id: Any) -> T | None:
38 query = self._create_query()

Callers 15

__init__Method · 0.80
transcription_daoFunction · 0.80
transcriptionMethod · 0.80
transcriptionMethod · 0.80
transcriptionMethod · 0.80
transcriptionMethod · 0.80
transcriptionMethod · 0.80

Calls 1

_create_queryMethod · 0.95