Questions tagged [upsert]
UPSERT is a combination of UPDATE and INSERT, typically used in relational databases.
1,186
questions
0
votes
1
answer
55
views
Postgres SQL UPSERT too slow query(Performance Issue)
I am trying to populate postgres table from another table, nearly about 24 millions records. but query become too slow it taking 9-10 hours. the update operation only update 1-2 row each second. i ...
2
votes
1
answer
32
views
Supabase - Upsert & multiple onConflict constraints
I cannot figure out how to proceed with an Upsert & "multiple" onConflict constraints. I want to push a data batch in a Supabase table.
My data array would be structured as follows:
...
-1
votes
0
answers
46
views
How to Upsert a pandas dataframe to postgres using INSERT ON CONFLICT DO UPDATE SET EXCLUDED query giving error
I have a pandas data frame, and I want to insert/update (upsert) it to a table. Condition is-
There will be an insert of new rows (this scenario will add current timestamp to the column ...
0
votes
0
answers
12
views
is there any possible way with upsert the document of array in mongodb [duplicate]
below example of document
[
{
"feed": '',
"title": '',
"items": [
{
'sku':'', //unique field
'field1':'',
'field2':'',
},
...
0
votes
1
answer
42
views
Databricks-Salesforce connection
I want to upsert data into salesforce object using azure databricks. I have tried using the springml for salesforce but can't seem to establish a connection
I have tried installing the springml ...
-1
votes
2
answers
75
views
Does DynamoDB's UpdateItemCommand have an "update only" mode?
I have some TypeScript code in a project that does a number of native DynamoDB update operations:
import { nativeDocumentClient, nativeDynamo } from '../utils/aws';
// snipped code
// ...
0
votes
0
answers
23
views
Updating documents with logastash
I have a solution with filebeat(on server) -> logstash(on server) -> elasticsearch(as service)
I have to ingest data from file.log in JSON format.
each row have an "GUID" element which ...
-1
votes
1
answer
26
views
Upserting entity in MongoDB with adding element to nested array in one operation
I have some entities like that:
{
"id": 1,
...
"items": [
{
"name": "name_1",
...
}
]
}
I need to upsert that document in ...
1
vote
2
answers
67
views
How to insert a row into another table during an on conflict
I want to insert in a ManyToMany relationship (between 'fiche' and quality) a line (same principle as a log) when an insertion fails because the key is duplicated.
example:
insert into fiche (content) ...
1
vote
1
answer
51
views
'DeltaMergeBuilder' object has no attribute 'WhenNotMatchedInsert'
while doing merge with deltatable getting below error.
'DeltaMergeBuilder' object has no attribute 'WhenNotMatchedInsert'
from delta.tables import *
delta_df = DeltaTable.forPath(spark,"dbfs:/...
0
votes
1
answer
20
views
Equivalent of insert or update in DynamoDB for counting
I'm trying to keep track of hits from IP addresses.
Typically, in a SQL database, you could do something along the lines of:
CREATE TABLE website_hits
(
ip VARCHAR(45) PRIMARY KEY,
hits ...
1
vote
1
answer
49
views
Merge Query With Delete From Target Condition
I am working on a task where my source is AWS RDS - SQL Server and my target is Azure SQL Server.
There's a table with 80M records in my source that needs to be merged with my target table.
This ...
1
vote
0
answers
30
views
Return identifier of conflicted insert in postgres [duplicate]
I want to insert rows into a table and return the identifier of the inserted row. Whenever a unique contraint is conflicted, I still want to return the identifier.
I ran the following query:
insert ...
0
votes
1
answer
31
views
Does unique constraint column needs to be added while doing upsert in laravel?
For example i have table orders in posgres DB
id
order_no
account_id
1
222
111
2
444
222
I have added unique constraint on order_no and account_id column. Now when I added new column and I want ...
0
votes
0
answers
24
views
Is there a single word that means "upsert or delete"?
I've written a function that upserts a row in to my database and deletes it if it's blank. I'm struggling to name it. If it only upserted, I'd just call it that. And if it only deleted, I'd just call ...
3
votes
1
answer
66
views
Why do I get an empty result in Postgres UPSERT with UNION
Trying the following UPSERT in PG (nodejs):
WITH upsert_result AS(
INSERT INTO table1 (col1, col2)
VALUES($1,$2)
ON CONFLICT DO NOTHING
RETURNING *
)
SELECT * FROM upsert_result
UNION
...
1
vote
1
answer
86
views
Upsert records in postgresql
I am working with postgresql database and I have below update query which works fine -
'UPDATE "main"."item_vendor"\n' +
' SET\n' +
' "vendor_id" = $1,...
0
votes
1
answer
34
views
When writing an upsert procedure, is using NULL parameters an idiomatic way to handle cases where the primary key only exists in the update case?
I have a table that has one column, an auto-increment column, as its primary key. It has no other unique keys. I wish to write a stored procedure that upserts in to it. Because it only has one unique ...
0
votes
1
answer
47
views
Alternative of REPLACE (which is provided in Microsoft SQL Server) in Postgres
I need something like
REPLACE into table (id, name, age) values(1, "A", 19)
in Postgres. The above query only works in Microsoft SQL Server. What I need is to get a batch insert query in ...
0
votes
1
answer
34
views
Neo4j upsert with possibly new edge type
I am trying to create upsert logic in neo4j. I need to upsert two nodes and connect the two nodes with a relationship.
If there is an existing relationship that shares 3 specific properties, e1_id, ...
0
votes
1
answer
63
views
Update or insert a single ORM entry based on a unique (but not primary) key
env
python 3.10
SQLAlchemy: 1.4.44
db: mysql 8
description
I want to upsert a column instance extends Base.
I searched how to upseart, and find using insert(). https://docs.sqlalchemy.org/en/14/...
0
votes
2
answers
83
views
Is there a way to have custom SQL query on top of JPA repository to have BULK UPSERTS?
I have a snowflake database and it doesn't support unique constraint enforcement (https://docs.snowflake.com/en/sql-reference/constraints-overview.html).
I'm planning to have a method on JPA ...
0
votes
0
answers
14
views
SpringData JPA conditionally upsert
I have a sequence of messages need to be converted and saved into database. Messages come out of order and I want to make sure only the latest message is saved into database. Each message has a ...
0
votes
1
answer
47
views
How to update a column with INSERT ... ON CONFLICT only if the old value is NULL
INSERT INTO main_parse_user ("user_id","group_id", "username", "bio", "first_name")
VALUES ($1,$2,$3,$4,$5)
ON CONFLICT (user_id)
DO UPDATE
SET (&...
0
votes
2
answers
91
views
Getting "UNIQUE constraint failed" when using @Upsert in Android Room
Getting net.sqlcipher.database.SQLiteConstraintException: error code 19: UNIQUE constraint failed with : appointment.activity_id: when trying to do @Upsert with Android Room.
My understanding with @...
0
votes
0
answers
23
views
Update existing row in TargetExcelSheet with data in SourceExcelSheet , only if given key record value matches between source and target
I have SourceExcel with transactional data with a primary key (DM_No). For a unique record in Source Excel, Status and other Columns keep on changing.
I need to update these changed values in the ...
0
votes
1
answer
53
views
Azure Data Factory Copy Pipeline with Geography Data Type
I am trying to get a geography data type from a production DB to another DB on a nightly occurrence. I really wanted to leverage upsert as the write activity, but it seems that geography is not ...
0
votes
1
answer
132
views
ClickHouse deduplication/upsert with different functions per column
I have a ClickHouse table which looks like this:
CREATE TABLE test
(
id Int,
property_id Int,
created_at DateTime('UTC'),
modified_at DateTime('UTC'),
data Int,
json_str ...
0
votes
1
answer
175
views
Azure Data Factory - Copy Data Upsert only updating a single row at a time
I'm using Data Factory (well synapse pipelines) to ingest data from sources into a staging layer. I am using the Copy Data activity with UPSERT. However i found the performance of incrementally ...
0
votes
1
answer
127
views
update Parquet file format
my requirement is to read that and generate another set of parquet data into another ADLS folder.
do i need this into spark dataframes and perform upserts ?
0
votes
1
answer
90
views
Performance of UPSERT (ON CONFLICT) vs. two queries UPDATE or INSERT
My code needs to run on different versions of SQLite. I'm using PHP's SQLite3 extension. Various servers in my user base have different SQLite versions installed, 3.7 being the earliest so far.
My ...
0
votes
1
answer
126
views
EF Core upsert operation in C# application
I want to develop an application where if data exists based on multiple database columns, then EF Core should perform an update operation or else an insert operation.
Table Structure:
TableName - ...
0
votes
1
answer
90
views
Synapse/ADF pipeline error 2200 on upserting CSV into on-prem SQL-server table
In my pipeline I perform an upsert from a flat CSV file (semicolon separated) into a table in our on-premise SQL-server. At first all the data types from the CSV file are read as STRING and I did the ...
0
votes
1
answer
164
views
SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders Laravel 8 upsert
Getting error
SQLSTATE[HY000]: General error: 1390 Prepared statement contains too
many placeholders...
while upsert large data.
Here is my code:
$reportItem = ReportItem::upsert($data->toArray(),...
-1
votes
1
answer
22
views
Using MERGE command in Upsolver
I would like to use Upsolver MERGE command in my new transformations to populates S3/Athena and Snowflake tables. Since Snowflake is supporting Upsert command, while defining my transformation job, ...
0
votes
1
answer
235
views
Insert or update if primary key exists into postgreSQL table with .to_sql()
I have a pandas DataFrame that consists of multiple columns that I want to store into the postgreSQL database, using .to_sql():
my_table.to_sql('table', con=engine, schema='wrhouse', if_exists='append'...
1
vote
1
answer
44
views
How to return ids of rows with conflicting values?
I am looking to insert or update values in an SQLite database (version > 3.35) avoiding multiple queries. upsert along with returning seems promising :
CREATE TABLE phonebook2(
name TEXT PRIMARY ...
0
votes
0
answers
39
views
EF Core - Upsert not adding Id column
I have the following entity :
public sealed class StrengthUnit : Entity
{
public string Code { get; private set; }
private StrengthUnit(Guid id, string code) : base(id)
{
Code = ...
0
votes
1
answer
25
views
postgresql upsert on view with triggers
I'm working with a postgresql 14 database where I have access to data through a view schema, and inserts and updates are performed with triggers. There is a unique constraint on the storage table, and ...
0
votes
0
answers
22
views
How to reference the alias of a table in the EXCLUDED of an UPSERT in PostgreSQL?
I want to reference table "b" in the EXCLUDED of the following UPSERT, but when I want to do it I get 'There is an entry for table "b", but it cannot be referenced from this part ...
0
votes
0
answers
60
views
MySQL UPSERT on specific column
I want to insert multiple values to a mysql table but if a specific column is duplicated then update the current row, I already know the insert into on duplicate key statement, but I want to make the ...
0
votes
0
answers
75
views
ADF Upsert to On-Prem Upserting Line-By-Line instead of Merging
Looking for a bit of help around an insanely slow ADF copy-data activity to an on-prem database.
We've configured a Copy-Data ADF task an 'Upsert' to an on-prem SQL DB via a dedicated 'Staging'. And ...
-1
votes
2
answers
204
views
Upsert in generic EF core repository
While it feels that this question should have been answered many times already, I can not find anything useful (except for BulkInsert addons which I'd like to avoid)
public virtual void ...
0
votes
2
answers
80
views
How to add columns from one MySQL table to another without duplicates?
There are two tables. It is necessary to insert two fields from one to the other so that duplicates do not appear. I tried those methods that are described for
USING INSERT IGNORE
Using replace
...
0
votes
0
answers
6
views
Update and fetch records in Mongo usingvspring
After upsert, not fetching the updated records.
After updating I f I fetch the records then updated records should come in same endpoint itself
0
votes
1
answer
32
views
Errors with INSERT ... ON CONFLICT
I have this code below
INSERT INTO table1 (code, value)
VALUES ('code1', 'value1')
ON CONFLICT (code, value)
WHERE code = 'code1'
DO
UPDATE SET value = 'value1';
When I try running this code I ...
0
votes
1
answer
24
views
How can I indicate the "current" column in an upsert in PostgreSQL?
I have the following upsert with which I have problems because the subqueries give me more than one result. The problem is that I don't know how to indicate in the upsert to compare the value of the ...
1
vote
1
answer
49
views
How to use delete while using merge to update and insert query in oracle?
I am working with both PostgreSQL and oracle for same query. while updating using PostgreSQL, remaining entries gets delete and whichever matched get update. Same query using merge in oracle didn't ...
0
votes
1
answer
91
views
Does `ON CONFLICT` in postgres use db locks to ensure there aren't any duplicate rows in POSTGRES?
Does ON CONFLICT DO NOTHING lock the table to ensure that we don't insert duplicate rows?
Can anyone share any notes on the internal working of ON CONFLICT on different cases?