func ExampleOpen() { f, err := ioutil.TempFile("./", "unqlite_") check(err) defer os.Remove(f.Name()) // Open file database. db, err := gounqlite.Open(f.Name()) check(err) db.Close() // Open in memory database. db, err = gounqlite.Open(":mem:") check(err) db.Close() }
func ExampleHandle_Store() { db, err := gounqlite.Open(":mem:") check(err) defer db.Close() db.Store([]byte("key"), []byte("value")) }
func ExampleHandle_Close() { db, err := gounqlite.Open(":mem:") check(err) err = db.Close() check(err) err = db.Close() fmt.Println(err) // Output: nil unqlite database }
func ExampleHandle_Fetch() { db, err := gounqlite.Open(":mem:") check(err) defer db.Close() v, err := db.Fetch([]byte("key")) fmt.Println(err) err = db.Store([]byte("key"), []byte{'a'}) v, err = db.Fetch([]byte("key")) check(err) fmt.Println(v) // Output: No such record // [97] }
func ExampleHandle_Append() { db, err := gounqlite.Open(":mem:") check(err) defer db.Close() db.Append([]byte("key"), []byte{'a'}) v, err := db.Fetch([]byte("key")) check(err) fmt.Println(v) db.Append([]byte("key"), []byte{'b'}) v, err = db.Fetch([]byte("key")) check(err) fmt.Println(v) // Output: [97] // [97 98] }