Created
February 14, 2014 04:29
-
-
Save apeace/8995806 to your computer and use it in GitHub Desktop.
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
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