Ejemplo n.º 1
0
func (c *SQLiteConn) exec(cmd string) (driver.Result, error) {
	pcmd := C.CString(cmd)
	defer C.free(unsafe.Pointer(pcmd))
	rv := C.sqlite3_exec(c.db, pcmd, nil, nil, nil)
	if rv != C.SQLITE_OK {
		return nil, c.lastError()
	}
	return &SQLiteResult{
		int64(C._sqlite3_last_insert_rowid(c.db)),
		int64(C._sqlite3_changes(c.db)),
	}, nil
}
Ejemplo n.º 2
0
// Execute the statement with arguments. Return result object.
func (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
	if err := s.bind(args); err != nil {
		return nil, err
	}
	rv := C.sqlite3_step(s.s)
	if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
		return nil, s.c.lastError()
	}

	res := &SQLiteResult{
		int64(C._sqlite3_last_insert_rowid(s.c.db)),
		int64(C._sqlite3_changes(s.c.db)),
	}
	return res, nil
}
Ejemplo n.º 3
0
// Return how many rows affected.
func (r *SQLiteResult) RowsAffected() (int64, error) {
	return int64(C._sqlite3_changes(r.s.c.db)), nil
}