#1 2018-12-03 20:02:25

greedy
Member
Registered: 2018-10-26
Posts: 11

Load library from Appdir via TSQLDBZEOSConnectionProperties

Hey,
I want to reach that my app only uses libraries which are in an 'external' folder inside my app but how can I load a library only from my app dir with TSQLDBZEOSConnectionProperties?

My actual code looks like this:

TSQLDBZEOSConnectionProperties.Create(TSQLDBZEOSConnectionProperties.URI(dMySQL, server_port), dbname, user, pass);

I know that I can define a library name with the 3rd parameter but how would you do that for MySQL?

Zeos defines

  MARIADB_LOCATION = 'libmariadb'+ SharedSuffix;
  DLL_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix;
{$IFDEF MSWINDOWS}
  WINDOWS_DLL_LOCATION = 'libmysql.dll';
  WINDOWS_DLL41_LOCATION = 'libmysql41.dll';
  WINDOWS_DLL41_LOCATION_EMBEDDED = 'libmysqld41.dll';
  WINDOWS_DLL50_LOCATION = 'libmysql50.dll';
  WINDOWS_DLL50_LOCATION_EMBEDDED = 'libmysqld50.dll';
  WINDOWS_DLL51_LOCATION = 'libmysql51.dll';
  WINDOWS_DLL51_LOCATION_EMBEDDED = 'libmysqld51.dll';
  WINDOWS_DLL55_LOCATION = 'libmysql55.dll';
  WINDOWS_DLL55_LOCATION_EMBEDDED = 'libmysqld55.dll';
  WINDOWS_DLL56_LOCATION = 'libmysql56.dll';
  WINDOWS_DLL56_LOCATION_EMBEDDED = 'libmysqld56.dll';
  WINDOWS_DLL57_LOCATION = 'libmysql57.dll';
  WINDOWS_DLL57_LOCATION_EMBEDDED = 'libmysqld57.dll';
{$ELSE}
  LINUX_DLL_LOCATION = 'libmysqlclient'+SharedSuffix;
  LINUX_DLL41_LOCATION = 'libmysqlclient'+SharedSuffix+'.14';
  LINUX_DLL41_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.14';
  LINUX_DLL50_LOCATION = 'libmysqlclient'+SharedSuffix+'.15';
  LINUX_DLL50_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.15';
  LINUX_DLL51_LOCATION = 'libmysqlclient'+SharedSuffix+'.16';
  LINUX_DLL51_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.16';
  LINUX_DLL55_LOCATION = 'libmysqlclient'+SharedSuffix+'.18';
  LINUX_DLL55_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.18';
  LINUX_DLL56_LOCATION = 'libmysqlclient'+SharedSuffix+'.19';
  LINUX_DLL56_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.19';
  LINUX_DLL57_LOCATION = 'libmysqlclient'+SharedSuffix+'.20';
  LINUX_DLL57_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.20';
{$ENDIF}

and I think the best way of coding would be to use all of those defines, so that someone don't need to maintain a copy of them or force a special name for the library in an app.
MySQL is just an example, the same issue would occur if you try the same with any other database driver from ZEOS...MySQL is just special because of MariaDB+MySQL.

Is it possible to add an option to URI function like

aLoadFromThisLocationOnly: : String= ''

, so it uses default ZEOS defines but only searches in a given path? I'd appreciate it!

Thanks in advance.

Offline

#2 2018-12-04 08:35:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Load library from Appdir via TSQLDBZEOSConnectionProperties

Isn't more a question for the Zeos/ZDBC forum?

Online

#3 2018-12-04 16:02:09

greedy
Member
Registered: 2018-10-26
Posts: 11

Re: Load library from Appdir via TSQLDBZEOSConnectionProperties

ab wrote:

Isn't more a question for the Zeos/ZDBC forum?

I'm not sure as

TSQLDBZEOSConnectionProperties

class is from mORMot tongue
But sure, I can ask there as well... smile

Offline

#4 2018-12-04 16:43:28

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: Load library from Appdir via TSQLDBZEOSConnectionProperties

@greedy

You don't need to do that today.

SynDBZeos.pas wrote:

....
    class function URI(aServer: TSQLDBDefinition;
      const aServerName: RawUTF8; const aLibraryLocation: TFileName='';
      aLibraryLocationAppendExePath: boolean=true): RawUTF8; overload;
...

just use the third param and define your lib.

Offline

#5 2018-12-04 21:04:52

greedy
Member
Registered: 2018-10-26
Posts: 11

Re: Load library from Appdir via TSQLDBZEOSConnectionProperties

@EgonHugeist
I'd need at least 3 names: libmariadb (windows+linux), libmysql (windows), libmysqlclient (linux)
In linux one could also symlink his exisiting library, e.g. libmysqlclient.so.16
How would I do that without forcing a special name for the library?

Even if I force them to use a special name for the library, how do you know if he uses mysql or mariadb library? Maybe they split more and more and don't work with the same library.

Last edited by greedy (2018-12-04 21:07:11)

Offline

Board footer

Powered by FluxBB