'How can I upload from one SQL db to another using sqlite3?
I am doing a staging table -> destination table set up where the only difference in columns is that I added created_date and last_updated for the destination and set a trigger for it.
I am having trouble finding the code to update if a unique ID exists or insert if a unique ID does not exist. Afterward, I would like to wipe off the staging table so as to prepare it for the next time I run the codes to fill it again. Note that I have to do all this on sqlite3 (python)
So far I've seen some codes like
UPDATE table1 SET table1.column1 =(SELECT table2.column1 FROM table2
WHERE table1.column2 = table2.column2);
However, this doesn't help me as I have like many columns and I just want to export the whole data and then just wipe the staging table. Also, this is just a single update statement I was thinking if sqlite3 has an if-else kinda thing.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
