Converting import stuff to a colon separated list approach.
This commit is contained in:
parent
ee343f17e9
commit
893faf8988
3 changed files with 33 additions and 16 deletions
BIN
.main.go.swp
Normal file
BIN
.main.go.swp
Normal file
Binary file not shown.
49
main.go
49
main.go
|
|
@ -1,13 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"strings"
|
||||||
// "reflect"
|
"os"
|
||||||
|
|
||||||
|
"database/sql"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type active_record interface {
|
type active_record interface {
|
||||||
init(string, int) bool
|
init(string, int) bool
|
||||||
|
|
@ -57,16 +57,33 @@ func prep_query(db *sql.DB, q string) (*sql.Stmt){
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func check(e error) {
|
||||||
// exec setup.sql to init
|
if e != nil {
|
||||||
cmd := exec.Command("sqlite3", "rpgqui.db < setup.sql")
|
panic(e)
|
||||||
out, err := cmd.Output()
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
|
||||||
log.Print(err)
|
func main() {
|
||||||
} else {
|
dat, err := os.ReadFile("setup.sql")
|
||||||
log.Print(out)
|
|
||||||
}
|
check(err)
|
||||||
|
|
||||||
// db, _ := sql.Open("sqlite3", "words.db")
|
log.Printf("contents: \n\n%s", dat)
|
||||||
|
|
||||||
|
queries := strings.Split(string(dat), ";")
|
||||||
|
|
||||||
|
log.Print(queries)
|
||||||
|
|
||||||
|
db, err := sql.Open("sqlite3", "rpgqui.db")
|
||||||
|
|
||||||
|
check(err)
|
||||||
|
|
||||||
|
for i, q := range queries {
|
||||||
|
log.Println(i, q)
|
||||||
|
|
||||||
|
res, err := db.Exec(q)
|
||||||
|
check(err)
|
||||||
|
|
||||||
|
log.Println(res)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
rpgqui.db
BIN
rpgqui.db
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue