Recent

Author Topic: Looking for an embedded SQL Database  (Read 6782 times)

teco

  • New Member
  • *
  • Posts: 31
Looking for an embedded SQL Database
« on: March 13, 2024, 10:22:30 am »
Hi,

I am looking for an embedded SQL Database I can include in an Windows application. I am trying to make a small cash box tool as single file application. So when I share it, I need only to give the application file and everything is included.

Thank you for help.


rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: Looking for an embedded SQL Database
« Reply #1 on: March 13, 2024, 10:57:34 am »
Your best bet would be SQLite3.
Easiest would be to just distribute the dll with your .exe.
If you really only want one .exe and absolutely no extra supporting files, you need to look into embedding sqlite3.obj into your .exe with static linking.

Like mORMot2 does: https://blog.synopse.info/?post/2019/09/21/SQLite3-static-linking-for-Delphi-Win64.
I'm not sure if there are examples of this here on the forum.


teco

  • New Member
  • *
  • Posts: 31
Re: Looking for an embedded SQL Database
« Reply #2 on: March 13, 2024, 11:06:21 am »
Your best bet would be SQLite3.
Easiest would be to just distribute the dll with your .exe.
If you really only want one .exe and absolutely no extra supporting files, you need to look into embedding sqlite3.obj into your .exe with static linking.

Like mORMot2 does: https://blog.synopse.info/?post/2019/09/21/SQLite3-static-linking-for-Delphi-Win64.
I'm not sure if there are examples of this here on the forum.

Dear rvk,
Thank for the information, but I am a hobby programmer and have never included an .obj file. I don't know how to do this without an example/tutorial.

Sorry.

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Looking for an embedded SQL Database
« Reply #3 on: March 13, 2024, 11:10:07 am »
In windows if you copy the libsqlite3.ddl in the same directory where the executable is, then this directory will be used as library search path, so the easiest way with the dll is easy to do.
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Thaddy

  • Hero Member
  • *****
  • Posts: 16387
  • Censorship about opinions does not belong here.
Re: Looking for an embedded SQL Database
« Reply #4 on: March 13, 2024, 11:14:35 am »
For a truly embedded database, link f.e. SQLite statically. That is the true meaning of embedded, btw.
Ignore any other nitwits.
Embedded means single executable, no dependencies.
Alas the term is used rather loosely. (FB)
« Last Edit: March 13, 2024, 11:17:31 am by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

teco

  • New Member
  • *
  • Posts: 31
Re: Looking for an embedded SQL Database
« Reply #5 on: March 13, 2024, 11:21:27 am »
For a truly embedded database, link f.e. SQLite statically. That is the true meaning of embedded, btw.
Ignore any other nitwits.
Embedded means single executable, no dependencies.
Alas the term is used rather loosely. (FB)

Thank you. This is exactly what I am looking for.
Is there an example for hobby programmer to recommend? I have no expericence with static linking.

Zvoni

  • Hero Member
  • *****
  • Posts: 2795
Re: Looking for an embedded SQL Database
« Reply #6 on: March 13, 2024, 11:36:18 am »
In windows if you copy the libsqlite3.ddl in the same directory where the executable is, then this directory will be used as library search path, so the easiest way with the dll is easy to do.
There is no libsqlite3.dll ......
.... it doesn't exist.....

That said: What Thaddy said. Static linking is the way
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Thaddy

  • Hero Member
  • *****
  • Posts: 16387
  • Censorship about opinions does not belong here.
Re: Looking for an embedded SQL Database
« Reply #7 on: March 13, 2024, 11:53:59 am »
I will add an examlpe later, but mORMot has also an example. Linking object files is not difficult at all once you know how to do it. You do not need any dll's. (that would mean fake embedded  :) )
RVK and I are on the same line, I believe.
« Last Edit: March 13, 2024, 11:58:27 am by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Looking for an embedded SQL Database
« Reply #8 on: March 13, 2024, 12:10:21 pm »
In windows if you copy the libsqlite3.ddl in the same directory where the executable is, then this directory will be used as library search path, so the easiest way with the dll is easy to do.
There is no libsqlite3.dll ......
.... it doesn't exist.....

That said: What Thaddy said. Static linking is the way

Sorry, correct name is "sqlite3.dll".
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Чебурашка

  • Hero Member
  • *****
  • Posts: 586
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Looking for an embedded SQL Database
« Reply #9 on: March 13, 2024, 12:13:32 pm »
I will add an examlpe later...

Despite so far I always followed the external library approach both in windows and linuxes, I am also interested in the topic of static linking, so I look forward for this post, as it will be very useful knowledge.
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Zvoni

  • Hero Member
  • *****
  • Posts: 2795
Re: Looking for an embedded SQL Database
« Reply #10 on: March 13, 2024, 12:32:33 pm »
I will add an examlpe later...

Despite so far I always followed the external library approach both in windows and linuxes, I am also interested in the topic of static linking, so I look forward for this post, as it will be very useful knowledge.

In a nutshell:
{$LinkLib LIBNAME} --> you need the LIBNAME.a file
{$Link LIBNAME} --> you need the LIBNAME.o file

In any case, your Declarations are as follows:

Function SomeFunction(SomeArguments):SomeReturnType;call_convention;external; --> NO LIBNAME!!

call_convention whatever the lib is compiled with. On Windows usually stdcall, in case of sqlite3 though it's cdecl
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

MarkMLl

  • Hero Member
  • *****
  • Posts: 8111
Re: Looking for an embedded SQL Database
« Reply #11 on: March 13, 2024, 02:18:43 pm »
In a nutshell:
{$LinkLib LIBNAME} --> you need the LIBNAME.a file
{$Link LIBNAME} --> you need the LIBNAME.o file

Thanks for that, useful and concise summary.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Zvoni

  • Hero Member
  • *****
  • Posts: 2795
Re: Looking for an embedded SQL Database
« Reply #12 on: March 13, 2024, 02:31:16 pm »
In a nutshell:
{$LinkLib LIBNAME} --> you need the LIBNAME.a file
{$Link LIBNAME} --> you need the LIBNAME.o file

Thanks for that, useful and concise summary.

MarkMLl

Sidenote: difference between "a" and "o"-files (at least as i understand it).
"o"-files are usually the compile-output of a single source-code-unit (e.g. "mycode.c" --> "mycode.o")
"a"-files are more like an archive, that can contain multiple "o"-files

Difference in Linking:
specified "o"-files get sucked into the final executable. Period
a specified "a"-file only sucks in those "o"-files you actually try to access in your code

See here: https://stackoverflow.com/questions/654713/o-files-vs-a-files
Answer by Tom Böhmer
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: Looking for an embedded SQL Database
« Reply #13 on: March 13, 2024, 03:38:44 pm »
I will add an examlpe later, but mORMot has also an example. Linking object files is not difficult at all once you know how to do it. You do not need any dll's. (that would mean fake embedded  :) )
RVK and I are on the same line, I believe.
Yep. I agree. FB has 'fake' embedding.
But saying that... so does SQLite3 on Windows in standard FPC.
I don't see any static loading code of SQLite3 for Windows in the sources.
Or am I looking at the wrong place?

So SQLite3 also has always been 'fake' embedded  :D

Only way I see it is using mORMot2 at the moment (or changing a lot of code in FPC).

Zvoni

  • Hero Member
  • *****
  • Posts: 2795
Re: Looking for an embedded SQL Database
« Reply #14 on: March 13, 2024, 03:53:00 pm »
Yep. I agree. FB has 'fake' embedding.
But saying that... so does SQLite3 on Windows in standard FPC.
I don't see any static loading code of SQLite3 for Windows in the sources.
Or am I looking at the wrong place?

So SQLite3 also has always been 'fake' embedded  :D

Only way I see it is using mORMot2 at the moment (or changing a lot of code in FPC).
Would have to agree. It's "fake" static/embedded.
The crucial file is sqlite3.inc, so if anyone is up for it? :D :D
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018