December 2017
Intermediate to advanced
316 pages
6h 58m
English
All SQLite3 operations are going to be done using a library called go-sqlite3. We can install that package using the following command:
go get github.com/mattn/go-sqlite3
The special thing about this library is that it uses the internal sql package of Go. We usually import database/sql and use sql to execute database queries on the database (here, SQLite3):
import "database/sql"
Now, we can create a database driver and then execute the SQL commands on it using a method called Query:
sqliteFundamentals.go:
package mainimport ( "database/sql" "log" _ "github.com/mattn/go-sqlite3")// Book is a placeholder for booktype Book struct { id int name string author string}func main() { db, err := sql.Open("sqlite3", ...