How to INSERT and UPDATE many rows in python pyodbc?

Asked 1 years ago, Updated 1 years ago, 108 views

Regardless of the database in pspark or python (I would like you to let me know around mssql and postgreSQL), you need to insert or update coding for each row.

However, Spark does not support update, so it works as a Python library I'm going to check the pk value by row, and if there's none, I'm going to order INSERT, and if there is, I'm going to order UPDATE It's taking too long.Is there an efficient way?

python mssql python3 sql

2022-09-20 18:58

1 Answers

If it is mssql, there is a MERGE statement, but due to the nature of the work you are doing, it will never be efficient if you check each data is subject to UPDATE.

Usually, INSERT is used only for INSERT, and UPDATE is handled in a lump later. INSERT is less expensive than UPDATE and less likely to cause a deadlock.

If you tell me to do this...

I think it's going to be either.


2022-09-20 18:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.