mirror of
https://github.com/geektutu/7days-golang.git
synced 2024-04-21 12:32:11 +00:00
21 lines
522 B
Go
Executable File
21 lines
522 B
Go
Executable File
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"geeorm"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
func main() {
|
|
engine, _ := geeorm.NewEngine("sqlite3", "gee.db")
|
|
defer engine.Close()
|
|
s := engine.NewSession()
|
|
_, _ = s.Raw("DROP TABLE IF EXISTS User;").Exec()
|
|
_, _ = s.Raw("CREATE TABLE User(Name text);").Exec()
|
|
_, _ = s.Raw("CREATE TABLE User(Name text);").Exec()
|
|
result, _ := s.Raw("INSERT INTO User(`Name`) values (?), (?)", "Tom", "Sam").Exec()
|
|
count, _ := result.RowsAffected()
|
|
fmt.Printf("Exec success, %d affected\n", count)
|
|
|
|
}
|