SQLITE import records, export only new records

Arkham Angel

I have records that will get imported every hour to a table. The records are often duplicates. I want to delete any duplicates, note which records are new and then copy/move/export them somewhere else.

How can I do this?

Arkham Angel

I created two tables that are the same. I initially populate data into TableA and then copied everything from TableA into TableB.

INSERT INTO TableB SELECT * FROM TableA;

When new data streams into TableA, I go:

    DELETE FROM TableA
WHERE EXISTS
  (SELECT *
   FROM TableB
   WHERE TableA.field1 = TableB.field1);

And then, I do what I need to do with the data in TableA and then copy everything from TableA to TableB again.

INSERT INTO TableB SELECT * FROM TableA;

Repeat as often as new data streams into TableA and repeat. This keeps only "fresh" data in TableA. Please advise if there is a more elegant solution.

Thanks again.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Stopping duplicate records in SQLite

From Dev

Count adjacent records in sqlite

From Dev

"No explicit conversion of Symbol into String" for new records in rails 4.0.1 (only)

From Dev

Only display new records in a MS Access continuous form

From Dev

Import and Create Records from CSV

From Dev

Insert new records only into SQL Table Using VBA

From Dev

Export and import SQLite database

From Dev

Import Multiple Records Into CRM

From Dev

Insert multiple records and/or update specific fields and return only new records inserted (MongoDB)

From Dev

SQLite Concat and JOIN of records

From Dev

Count adjacent records in sqlite

From Dev

Retrieve only associated records

From Dev

Autonumber in inputting new records

From Dev

Sqlite get records by hour

From Dev

Import new XML data into MySQL table without affecting existing records

From Dev

SQL: insert only new records

From Dev

Only display new records in a MS Access continuous form

From Dev

In an Android app, where do new SQLite records get saved to in the filesystem?

From Dev

Check for new records

From Dev

Total records in sqlite table

From Dev

ActiveAdmin csv export records order

From Dev

How to push only new records in a local MongoDB to another remote instance?

From Dev

Calculate new column in pandas dataframe based only on grouped records

From Dev

How to using django-import-export to export records sorted by a different column?

From Dev

SQlite not updating records

From Dev

How do you append new records only in query?

From Dev

Export sql records with bash

From Dev

Handling new records in meteor

From Dev

Pivot in SQLite with missing records

Related Related

HotTag

Archive