我有一个名为WVDList
的表,存储在一个名为compFleet.db
的sqlite数据库中。我在R中运行脚本以从API收集新数据,然后使用R中WVDList
包中的函数将其追加到DBI
。
db_con <- dbConnect(RSQLite::SQLite(), "data/compfleet.db")
dbWriteTable(db_con, "WVDList", WVDList, append=TRUE)
但是,调用API有时会返回数据库中已经存在的记录。如何仅追加数据库表中不存在的那些行?
对API的每次调用通常返回超过1000,000行。列名是
c("mmsi", "lat", "lon", "rateOfTurn", "sogKts", "cog", "heading",
"timestamp", "imoNumber", "dimensionToBow", "dimensionToStern",
"dimensionToPort", "dimensionToStarboard", "etaMonth", "etaDay",
"etaHour", "etaMinute", "draught", "name", "destination", "callsign"
)