std::stringsql("SELECT COUNT(*) FROM LHEARD WHERE callsign='");
sql.append(callsign);
sql.append("';");
intcount=0;
std::stringstreamsql;
sql<<"INSERT OR REPLACE INTO LHEARD (callsign,sfx,module,reflector,lasttime) VALUES ('"<<callsign<<"','"<<sfx<<"','"<<module<<"','"<<reflector<<"',strftime('%s','now'));";
std::stringsql("UPDATE LHEARD SET (maidenhead,latitude,longitude,lasttime) = ('");
sql.append(maidenhead);
sql.append("',");
sql.append(std::to_string(latitude));
sql.append(",");
sql.append(std::to_string(longitude));
sql.append(",");
sql.append("strftime('%s','now')) WHERE callsign='");
sql.append(callsign);
sql.append("';");
std::stringstreamsql;
sql<<"UPDATE LHEARD SET (maidenhead,latitude,longitude,lasttime) = ('"<<maidenhead<<"',"<<latitude<<","<<longitude<<",strftime('%s','now')) WHERE callsign='"<<callsign<<"';";
std::stringsql="INSERT OR REPLACE INTO LINKSTATUS (ip_address,from_mod,to_callsign,to_mod,linked_time) VALUES ('";
sql.append(address);
sql.append("','");
sql.append(1,from_mod);
sql.append("','");
sql.append(to_callsign);
sql.append("','");
sql.append(1,to_mod);
sql.append("',");
sql.append(std::to_string(linked_time).c_str());
sql.append(");");
std::stringstreamsql;
sql<<"INSERT OR REPLACE INTO LINKSTATUS (ip_address,from_mod,to_callsign,to_mod,linked_time) VALUES ('"<<address<<"','"<<from_mod<<"','"<<to_callsign<<"','"<<to_mod<<"',"<<linked_time<<");";