Skip to content

Instantly share code, notes, and snippets.

@OdinsPlasmaRifle
Last active October 11, 2017 12:59
Show Gist options
  • Save OdinsPlasmaRifle/21655142ce7fc8fd8f2b1a1ea21be83a to your computer and use it in GitHub Desktop.
Save OdinsPlasmaRifle/21655142ce7fc8fd8f2b1a1ea21be83a to your computer and use it in GitHub Desktop.
Basic SQLite Usage in Go
import (
"database/sql"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
func main() {
db, err := sql.Open("sqlite3", "db.sql")
if err != nil {
fmt.Printf("%v", err)
}
stmt, err := db.Prepare("INSERT INTO table_1 (col_1, col_2) VALUES (?, ?)")
if err != nil {
fmt.Printf("%v", err)
}
_, err = stmt.Exec("foo", "bar")
if err != nil {
fmt.Printf("%v", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment