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
|
id int
|
||||||
table_name string
|
table_name string
|
||||||
columns []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 {
|
type Entity struct {
|
||||||
id int
|
id int
|
||||||
user_id int
|
user_id int
|
||||||
|
|
@ -63,23 +52,12 @@ func check(e error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func reset_database(db *sql.DB) {
|
||||||
dat, err := os.ReadFile("setup.sql")
|
dat, _ := os.ReadFile("setup.sql")
|
||||||
|
|
||||||
check(err)
|
|
||||||
|
|
||||||
log.Printf("contents: \n\n%s", dat)
|
|
||||||
|
|
||||||
queries := strings.Split(string(dat), ";")
|
queries := strings.Split(string(dat), ";")
|
||||||
|
|
||||||
log.Print(queries)
|
|
||||||
|
|
||||||
db, err := sql.Open("sqlite3", "rpgqui.db")
|
|
||||||
|
|
||||||
check(err)
|
|
||||||
|
|
||||||
for i, q := range queries {
|
for i, q := range queries {
|
||||||
log.Println(i, q)
|
log.Println(i)
|
||||||
|
|
||||||
res, err := db.Exec(q)
|
res, err := db.Exec(q)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
@ -87,3 +65,9 @@ func main() {
|
||||||
log.Println(res)
|
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),
|
name VARCHAR(64),
|
||||||
spawn_line VARCHAR(64),
|
spawn_line VARCHAR(64),
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id)
|
FOREIGN KEY(user_id) REFERENCES users(id)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue