-
Notifications
You must be signed in to change notification settings - Fork 49
/
formatter_sqlite.go
39 lines (31 loc) · 1 KB
/
formatter_sqlite.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package formatter
import (
// Written this way to avoid automatic removal by text editor
"fmt"
// import sqlite library, mainly used only in formatter package
_ "github.com/mattn/go-sqlite3"
)
// sqliteStringDelimiter is a hardcoded string that is used to join
// certain values together in database
const sqliteStringDelimiter = ", "
// SqliteFormatter is a main struct to handle output for Sqlite
type SqliteFormatter struct {
config *Config
}
// Format the data to sqlite format and insert it into appropriate output (Sqlite DSN)
func (f *SqliteFormatter) Format(td *TemplateData, templateContent string) error {
db, err := NewSqliteDB(f.config)
if err != nil {
return fmt.Errorf("could not create new sqlite instance: %v", err)
}
err = db.prepare()
if err != nil {
return fmt.Errorf("failed to prepare db: %v", err)
}
err = db.populate(&td.NMAPRun)
return db.finish(err)
}
// defaultTemplateContent does not return anything
func (f *SqliteFormatter) defaultTemplateContent() string {
return ""
}