Ho circa 200 copie di un database SQLite. Tutti presi in tempi diversi con dati diversi in loro. Alcune righe vengono eliminate e alcune vengono aggiunte. Sono tutti in un'unica directory.Unire più backup dello stesso schema tabella in 1 tabella principale
Voglio unire tutte le righe nella tabella my_table
, utilizzando tutti i file .db
nella directory. Voglio che le righe duplicate siano cancellate, mostrando tutte le entrate da tutti i database, solo una volta.
Mi piacerebbe farlo in puro SQL, ma non credo sia possibile, quindi possiamo usare anche Python.
definizione Tabella:
CREATE TABLE my_table (
ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
guid TEXT UNIQUE NOT NULL,
text TEXT,
replace INTEGER DEFAULT 0,
service_center TEXT,
handle_id INTEGER DEFAULT 0,
subject TEXT,
country TEXT,
attributedBody BLOB,
version INTEGER DEFAULT 0,
type INTEGER DEFAULT 0,
service TEXT,
account TEXT,
account_guid TEXT,
error INTEGER DEFAULT 0,
date INTEGER,
date_read INTEGER,
date_delivered INTEGER,
is_delivered INTEGER DEFAULT 0,
is_finished INTEGER DEFAULT 0,
is_emote INTEGER DEFAULT 0,
is_from_me INTEGER DEFAULT 0,
is_empty INTEGER DEFAULT 0,
is_delayed INTEGER DEFAULT 0,
is_auto_reply INTEGER DEFAULT 0,
is_prepared INTEGER DEFAULT 0,
is_read INTEGER DEFAULT 0,
is_system_message INTEGER DEFAULT 0,
is_sent INTEGER DEFAULT 0,
has_dd_results INTEGER DEFAULT 0,
is_service_message INTEGER DEFAULT 0,
is_forward INTEGER DEFAULT 0,
was_downgraded INTEGER DEFAULT 0,
is_archive INTEGER DEFAULT 0,
cache_has_attachments INTEGER DEFAULT 0,
cache_roomnames TEXT,
was_data_detected INTEGER DEFAULT 0,
was_deduplicated INTEGER DEFAULT 0,
is_audio_message INTEGER DEFAULT 0,
is_played INTEGER DEFAULT 0,
date_played INTEGER,
item_type INTEGER DEFAULT 0,
other_handle INTEGER DEFAULT -1,
group_title TEXT,
group_action_type INTEGER DEFAULT 0,
share_status INTEGER,
share_direction INTEGER,
is_expirable INTEGER DEFAULT 0,
expire_state INTEGER DEFAULT 0,
message_action_type INTEGER DEFAULT 0,
message_source INTEGER DEFAULT 0
)
Mostra la definizione della tabella. –
@CL. aggiunto a quanto sopra. – User
Come vengono identificate le voci? Di 'rowid' o di' guid'? –