Cleaning stuff out a bit... Need to work towards querying.
This commit is contained in:
parent
893faf8988
commit
edbdfe3afc
4 changed files with 10 additions and 26 deletions
BIN
.main.go.swp
BIN
.main.go.swp
Binary file not shown.
34
main.go
34
main.go
|
|
@ -21,19 +21,8 @@ type ActiveSqliteRow struct {
|
|||
id int
|
||||
table_name string
|
||||
columns []string
|
||||
// values map[string]
|
||||
}
|
||||
/*
|
||||
func (r ActiveSqliteRow) init(t string, i int) bool{
|
||||
log.Print("In init with" + t)
|
||||
log.Print(i)
|
||||
|
||||
r.id = i
|
||||
r.table_name = t
|
||||
|
||||
return true
|
||||
}
|
||||
*/
|
||||
type Entity struct {
|
||||
id int
|
||||
user_id int
|
||||
|
|
@ -63,23 +52,12 @@ func check(e error) {
|
|||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
dat, err := os.ReadFile("setup.sql")
|
||||
|
||||
check(err)
|
||||
|
||||
log.Printf("contents: \n\n%s", dat)
|
||||
|
||||
func reset_database(db *sql.DB) {
|
||||
dat, _ := os.ReadFile("setup.sql")
|
||||
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)
|
||||
log.Println(i)
|
||||
|
||||
res, err := db.Exec(q)
|
||||
check(err)
|
||||
|
|
@ -87,3 +65,9 @@ func main() {
|
|||
log.Println(res)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
db, _ := sql.Open("sqlite3", "rpgqui.db")
|
||||
|
||||
reset_database(db)
|
||||
}
|
||||
|
|
|
|||
BIN
rpgqui.db
BIN
rpgqui.db
Binary file not shown.
|
|
@ -12,4 +12,4 @@ CREATE TABLE IF NOT EXISTS entities (
|
|||
name VARCHAR(64),
|
||||
spawn_line VARCHAR(64),
|
||||
FOREIGN KEY(user_id) REFERENCES users(id)
|
||||
);
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue