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 }
// 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 }
// Return last inserted ID. func (r *SQLiteResult) LastInsertId() (int64, error) { return int64(C._sqlite3_last_insert_rowid(r.s.c.db)), nil }