MCPcopy Create free account
hub / github.com/AdRoll/baker / NewSQLite

Function NewSQLite

output/sqlite.go:126–161  ·  view source on GitHub ↗
(isRaw bool)

Source from the content-addressed store, hash-verified

124}
125
126func NewSQLite(isRaw bool) func(baker.OutputParams) (baker.Output, error) {
127 return func(cfg baker.OutputParams) (baker.Output, error) {
128 // Convert and validate configuration
129 var dcfg *SQLiteRawWriterConfig
130 if isRaw {
131 dcfg = cfg.DecodedConfig.(*SQLiteRawWriterConfig)
132 } else {
133 dcfg = cfg.DecodedConfig.(*SQLiteConfig).convert()
134 }
135
136 path, err := renderSQLitePathString(dcfg.PathString, cfg.Index, "")
137 if err != nil {
138 return nil, fmt.Errorf("can't render PathString: %s", err)
139 }
140
141 // Make a record of all field names; they will be needed when we create
142 // an SQL table in the SQLite file.
143 var fieldNames []string
144 for _, fidx := range cfg.Fields {
145 fieldNames = append(fieldNames, cfg.FieldNames[fidx])
146 }
147
148 sqlw := &SQLite{
149 cfg: dcfg,
150 pathString: path,
151 fieldNames: fieldNames,
152 isRaw: isRaw,
153 }
154
155 if err = sqlw.setup(); err != nil {
156 return nil, fmt.Errorf("setup error: %v", err)
157 }
158
159 return sqlw, nil
160 }
161}
162
163func (c *SQLite) setup() error {
164 var err error

Callers 1

sqlite.goFile · 0.85

Calls 3

setupMethod · 0.95
renderSQLitePathStringFunction · 0.85
convertMethod · 0.80

Tested by

no test coverage detected