1 (edited by manixs2013 2018-09-17 10:54:05)

Topic: SYNC sqlite to online databse

Hello MVD!

Is there a way to sync local sqlite database to online database.? My point here if the internet is available that is the time the synchronization will take effect. if there is a way, pls give us a solution or a sample.

Thanks in advance!

manixs

Re: SYNC sqlite to online databse

Hello.


It's possible.
You can connect to MySQL and execute SQL queries for INSERT data to MySQL when you use SQLite, example:

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
var
    MySQL: TMyConnection;
begin
    MySQL := TMyConnection.Create(Form1);
    try
            MySQL.Options.UseUnicode := True;
            MySQL.Server := '127.0.0.1'; // ip address of MySQL server
            MySQL.Port := 3306;
            MySQL.Username := 'username';
            MySQL.Password := 'password';
            MySQL.Database := 'databasename';
            MySQL.LoginPromt := False;

            try
                MySQL.Connect;
            except
                ShowMessage('Can''t connect to database.');
            end;

            if MySQL.Connected then
            begin
                MySQL.ExecSQL('INSERT INTO test (field1, field2) VALUES ("value1", "value2")');
                MySQL.Disconnect;                                                                                         
            end;

    finally
        MySQL.Free;
    end;
end;


Unfortunately I don't have example for sync.

Dmitry.