Skip to content

Instantly share code, notes, and snippets.

@apeace
Created February 14, 2014 04:29
Show Gist options
  • Save apeace/8995806 to your computer and use it in GitHub Desktop.
Save apeace/8995806 to your computer and use it in GitHub Desktop.
package sqlite
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
"testing"
)
func Test_SqliteDriver(t *testing.T) {
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
t.Error(err)
}
_, err = db.Exec("CREATE TABLE stuff(id INTEGER)")
if err != nil {
t.Error(err)
}
_, err = db.Exec("INSERT INTO stuff (id) VALUES(1), (2), (3), (4), (5), (6)")
if err != nil {
t.Error(err)
}
rows, err := db.Query("SELECT id FROM stuff")
if err != nil {
t.Error(err)
}
defer rows.Close()
for rows.Next() {
rows2, err := db.Query("SELECT id FROM stuff")
if err != nil {
t.Error(err)
}
rows2.Close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment