您如何在 Expo 中运行的 SQLite 中执行 UPSERT? [英] How do you do an UPSERT in SQLite that is running in Expo?

查看:55
本文介绍了您如何在 Expo 中运行的 SQLite 中执行 UPSERT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样简单的表格

I have a simplistic table like this

create table if not exists setup (
  key TEXT PRIMARY KEY,
  value TEXT
)

查看 SQLite 中的 UPSERT 的语法 我想出了这个

Looking at the syntax for UPSERT in SQLite I came up with this

insert into setup (key, value) values (?,?)
on CONFLICT (key) do update set value = ?

但我明白

错误:on"附近:语法错误(代码 1 SQLITE_ERROR)

Error: near "on": syntax error (code 1 SQLITE_ERROR)

我在更新插入语句中遗漏了什么吗?读起来感觉还行.

Am I missing something in my upsert statement? It looks okay when I read it.

我已经尝试过反引号并将整个 SQL 放在一行中.

I already tried backticking and putting the whole SQL into one line.

推荐答案

似乎在 Expo 中,他们可能使用的是旧版本.由于我的要求很简单,这实际上有效

Seems like in Expo, they may be using an older version. Since my requirements are simple this actually worked

insert or replace into setup (key, value) values (?,?)

这篇关于您如何在 Expo 中运行的 SQLite 中执行 UPSERT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆