MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / flushToSQLTable

Function flushToSQLTable

go/sqlfs/sql_writer.go:25–43  ·  view source on GitHub ↗
(db *sql.DB, table string)

Source from the content-addressed store, hash-verified

23)
24
25func flushToSQLTable(db *sql.DB, table string) func([]byte) error {
26 row := 0
27 return func(buf []byte) error {
28 if db == nil {
29 return fmt.Errorf("flushToSQLTable: no database connection")
30 }
31
32 if len(buf) > 0 {
33 block := base64.StdEncoding.EncodeToString(buf)
34 query := fmt.Sprintf("INSERT INTO %s (id, block) VALUES(%d, '%s')",
35 table, row, block)
36 if _, e := db.Exec(query); e != nil {
37 return fmt.Errorf("cannot flush to table %s: %v", table, e)
38 }
39 row++
40 }
41 return nil
42 }
43}
44
45func noopWrapUp() error {
46 return nil

Callers 1

newSQLWriterFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected