I have the remote database which is in PostgreSQL and I have inserted all the tables with their data in my local database, but I can't figure out how to detect any changes from the remote database to be updated in my local database.
the table from the remote database postgres is users the table from the local database mysql is users
func Searching() {
postgresqlusers, _ := GetUsersPostgres()
mysqlusers, _ := GetUsersMysql()
for _, valuepostgres := range postgresqlusers {
if len(mysqlusers) == 0 {
_, err := db.Exec("insert into user values(?,?,?)", valuepostgres.User_Id, valuepostgres.Uid, valuepostgres.Phone)
if err != nil {
fmt.Println(len(mysqlusers))
}
}
for _, valuemysql := range mysqlusers {
if valuepostgres.User_Id != valuemysql.User_Id {
_, err := db.Exec("insert into user values(?,?,?)", valuepostgres.User_Id, valuepostgres.Uid, valuepostgres.Phone)
if err != nil {
fmt.Println("data inserted successufly")
}
}
}
}
}
so both have the same structure, I made a script for the insertion with Go but I am stuck at updating changes automatically