Last active
October 11, 2017 12:59
-
-
Save OdinsPlasmaRifle/21655142ce7fc8fd8f2b1a1ea21be83a to your computer and use it in GitHub Desktop.
Basic SQLite Usage in Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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