Home » U++ Library support » U++ SQL » Sql object
Sql object [message #56198] |
Sun, 07 February 2021 18:07  |
mubeta
Messages: 77 Registered: October 2006
|
Member |
|
|
Hi everyone,
before before writing this post I read several posts on this topic, but I came to the conclusion that I had to change the code of the U ++ library.
The Sql object seems for now unable to be hooked at the free choice of the programmer to different DB connections. So that if the choice of a SQLite or MySQL type DB for example, depended on configuration choices to be left to the end user of the resulting app, it would be impossible to use the same U++ code to write an application, in fact for now, the SQL object must be built clearly indicating a connection since its compilation.
After hours and hours of testing, research, etc., I came to the unwanted decision to make the umpteenth change to the U++ library, moving the Sql.SetSession() method from private to public, and now I have finally managed to write a code that works on several DB chosen by the end user.
I do not understand why the presence of such a method has been left as private. If there are concerns about possible change errors at runtime, different mechanisms could be identified, but with a much more flexible object.
|
|
|
Re: Sql object [message #56202 is a reply to message #56198] |
Mon, 08 February 2021 06:42  |
|
Hi mubeta,
Years ago, I've been trying something similar. I've come with a solution, where the sql code was compiled as dynamic library, so the final program didn't even require mysql libraries to run, unless it was configured to use mysql. You can find the code on my github, if you're intrested: https://github.com/dolik-rce/thewatchdog/tree/master/src/Dyn amicSql
Note however few important things:
- The code is pretty old, ~7 years, it might not work with current U++.
- I do not use the code anymore, and don't maintain it, so I cannot guarantee or support it in anyway.
- It also needed little patch of U++ sources: https://github.com/dolik-rce/thewatchdog/blob/master/patch/M ySql.patch
- Only MySql and SQLite are implemented, but adding more options should be easy
- Actually the worst part was not to allow dynamic selection of engine, but to write queries in a way that is compatible with both sqlite and mysql. In theory there is ANSI SQL, which should be a common subset of all SQL languages, but reality is much different
Anyway, I hope this helps, or at least inspires you (or someone else in future) 
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Fri Apr 25 12:48:31 CEST 2025
Total time taken to generate the page: 0.00830 seconds
|