json-example
Yasuhiro Matsumoto 2022-05-28 23:24:03 +09:00
parent 5131ffb8eb
commit 2cd93c9677
No known key found for this signature in database
GPG Key ID: 622DE34DC490584B
1 changed files with 12 additions and 13 deletions

View File

@ -42,10 +42,10 @@ func main() {
log.Fatal(err)
}
stmt, err := tx.Prepare(`
insert into iris(
sepal_length, sepal_width, petal_length, petal_width, class)
values(?, ?, ?, ?, ?)
`)
insert into iris(
sepal_length, sepal_width, petal_length, petal_width, class)
values(?, ?, ?, ?, ?)
`)
if err != nil {
log.Fatal(err)
}
@ -82,15 +82,14 @@ func main() {
tx.Commit()
rows, err := db.Query(`select
json_object(
'sepal_length', sepal_length,
'sepal_width', sepal_width,
'petal_length', petal_length,
'petal_width', petal_width,
'class', class
)
from iris
`)
json_object(
'sepal_length', sepal_length,
'sepal_width', sepal_width,
'petal_length', petal_length,
'petal_width', petal_width,
'class', class
) from iris
`)
if err != nil {
log.Fatal(err)
}