使用更新查询更新sqlite表中的值时出现问题

时间:2019-06-19 11:11:34

标签: ios swift sqlite.swift

我正在 swift项目中实施 sqlite ,并且通过更新 query我正在更新来自value的一些table,但是我收到语法错误。我不确定为什么会收到错误

更新代码

 let updateStatementString = "UPDATE CreateInspDrawingDetail SET edit_file_name = \(self.imgbase64!) WHERE property_id = \(property_ID!) AND properties_drawings_id = \(self.drawingID!)"
 var updateStatement: OpaquePointer? = nil
 if sqlite3_prepare_v2(db, updateStatementString, -1, &updateStatement, nil) == SQLITE_OK {
        if sqlite3_step(updateStatement) == SQLITE_DONE {
               print("Successfully updated row.")
        } else {
               print("Could not update row.")
        }
      } else {
            print("UPDATE statement could not be prepared")
      }
      sqlite3_finalize(updateStatement)

我遇到如下的语法错误

  

“ /”附近:无法准备语法错误的UPDATE语句

我在查询中做错了什么,请告诉我

1 个答案:

答案 0 :(得分:1)

尝试

def insertionSort2(n, arr):
    for i in range(1,n):
        small=int(arr[i])
        j=i-1
        while j>=0 and int(arr[j])>small:
            arr[j+1]=arr[j]
            j-=1
        arr[j+1]=small
        print(' '.join(arr))
        print('\r')
if __name__ == '__main__':
    n = int(input())

    arr = input().rstrip().split()
    print(' '.join(arr))

    insertionSort2(n, arr)