MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / insertMessage

Method insertMessage

plugins/destination/sqlite/client/write.go:58–74  ·  view source on GitHub ↗
(ctx context.Context, tx *sql.Tx, m *message.WriteInsert)

Source from the content-addressed store, hash-verified

56}
57
58func (c *Client) insertMessage(ctx context.Context, tx *sql.Tx, m *message.WriteInsert) error {
59 table := m.GetTable()
60 sc := m.Record.Schema()
61 var sqlString string
62 if len(table.PrimaryKeys()) == 0 {
63 sqlString = c.insert(sc)
64 } else {
65 sqlString = c.upsert(sc)
66 }
67 vals := transformRecord(m.Record)
68 for _, v := range vals {
69 if _, err := tx.ExecContext(ctx, sqlString, v...); err != nil {
70 return fmt.Errorf("failed to execute '%s': %w", sqlString, err)
71 }
72 }
73 return nil
74}
75
76func (*Client) insert(sc *arrow.Schema) string {
77 var sb strings.Builder

Callers 1

WriteTableBatchMethod · 0.95

Calls 4

insertMethod · 0.95
upsertMethod · 0.95
ErrorfMethod · 0.80
transformRecordFunction · 0.70

Tested by

no test coverage detected