Ejemplo n.º 1
0
func (Driver) Open(name string) (driver.Conn, error) {
	n := C.CString(name)
	defer C.free(unsafe.Pointer(n))

	var conn Conn
	r := C.sqlite3_open(n, &conn.db)
	if r != C.SQLITE_OK {
		return &conn, driver.ErrBadConn
	}
	return &conn, nil
}
Ejemplo n.º 2
0
func (h *Handle) Open(filename string) (err string) {
	rv := C.sqlite3_open(C.CString(filename), &h.cptr)

	if rv != 0 {
		if nil != h.cptr {
			return h.ErrMsg()
		} else {
			return "Couldn't allocate memory for SQLite3"
		}
	}
	return ""
}
Ejemplo n.º 3
0
func sqlite_Open(filename string) (*Conn, os.Error) {
	var db *C.sqlite3
	name := C.CString(filename)
	defer C.free(unsafe.Pointer(name))
	rv := C.sqlite3_open(name, &db)
	if rv != 0 {
		return nil, Errno(rv)
	}
	if db == nil {
		return nil, os.NewError("sqlite succeeded without returning a database")
	}
	return &Conn{db}, nil
}