Echo - Multiple Types of Databases

Is there a sample project available that uses two different databases?  I'm thinking something like the Echo client/server example in EchoDemo_XDataServer.groupproj, but with MySQL on the server and SQLite on the clients?

You can use multiple types of databases. All you have to do is configure the connection (in TAureliusConnection) to the database you want. 

I seem to have the server working correctly, as it will create the echo tables and class tables in a blank MySQL database.


But, when the the EchoTestDemo application attempts to push data to the server, the following error message is presented:  "Data Type Conversion is Not Supported".  Please also reference a screenshot at:


I assume that there is some conversion occurring between SQLite and MySQL.

I've identified one possible section of code in the EchoTestDemo.exe application that may need updating to be able to use MySQL on the server (in RemoteModule.pas):



function TdmEcho.CreateConnection(const ADBName: string): IDBConnection;
var
  FileName: string;
begin
  // Refers to a SQLite database in the same directory as the executable,
  // with the name given by "DBName"
  FileName := TPath.ChangeExtension(ADBName, '.db');
  FileName := TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), FileName);
  Result := TSQLiteNativeConnectionAdapter.Create(FileName);
end;


This points to a local SQLite database to create a connection.  I assume I would need to change this to reference the MySQL database instead, but I'm not sure what to use for connection code.  Or, do I need to reference the Echo server?

I'd appreciate any guidance.




That piece of code creates the SQLite database. Aurelius doesn't create other databases. You have to create the MySQL database, and in CreateConnection you just return the connection to the created database.

The error you are getting is unfortunately a specific error of Aurelius, that happens when:

1. You use MySQL;
2. You use Blobs using Unicode encoding;
3. You are using a recent MySQL 8 client library (libmysql.dll)
4. Yo use FireDac.

Unfortunately you hit such condition. Nevertheless we will be releasing a fix in the next Aurelius update.
To workaround it now, you can just change one of the above conditions: Either try to use an older MySQL client library (5.x, for example), or test with a different database, or use a component different than FireDac. You can't change the Unicode Blob because that's what is mapped in Echo.
Following parameters may work at MySQL connection. 

      FDConnection.LoginPrompt := False;
      FDConnection.Params.Values['Database'] := '<mydatabase>';
      FDConnection.Params.Values['DriverID'] := 'MySQL';
      FDConnection.Params.Values['User_Name'] := username; ;
      FDConnection.Params.Values['Password'] := password; ;
      FDConnection.Params.Values['Server'] := address;
      FDConnection.Params.Values['StringFormat'] := 'Ansi';  // <<<<<<<<
      FDConnection.Params.Values['CharacterSet'] := 'utf8';  // <<<<<<<<
      FDConnection.Connected := True;

I have this working now under the four conditions Wagner listed and with Maffessoni's suggestion of these two lines added:


      FDConnection.Params.Values['StringFormat'] := 'Ansi';  // <<<<<<<<
      FDConnection.Params.Values['CharacterSet'] := 'utf8';  // <<<<<<<<

Many thanks!