Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 45 of 60 · Go

Embedding a SQLite Database with `modernc.org/sqlite`

Duration: 20 minutes

SQLite in Go

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

modernc.org/sqlite is a pure‑Go SQLite driver.

$ go get modernc.org/sqlite
import (
    "database/sql"
    _ "modernc.org/sqlite"
)

func main() {
    db, _ := sql.Open("sqlite", ":memory:")
    db.Exec(`CREATE TABLE users(id INTEGER PRIMARY KEY, name TEXT)`)
    db.Exec(`INSERT INTO users(name) VALUES(?)`, "Alice")
    var name string
    db.QueryRow(`SELECT name FROM users WHERE id=?`, 1).Scan(&name)
    fmt.Println(name) // Alice
}

Info

SQLite is great for small services, prototyping, or unit tests where you need a fast, file‑based DB.

Previous: Writing Benchmarks – `testing.B`Next: Building a HTTP/2 Server with TLS