The source code of the framework, now in version 1.4, can be downloaded in SynopseSQLite3.zip
Here are the highlighted modifications made to the framework:
- whole Synopse SQLite3 database framework released under the GNU Lesser General Public License version 3, instead of generic "Public Domain"
- fix a bug happening when multiple HTTP connections were opened and closed in the same program
- new HTTP Client/Server sample application
- HTTP/1.1 RESTFUL JSON Client and Server split into two units (SQLite3HttpClient and SQLite3HttpServer)
- Start the Project04Server.exe program: the background HTTP server, together with its SQLite3 database engine;
- Start any Project04Client.exe instances, and add/find any entry, to populate the database a little;
- Close the Project04Client.exe programs, if you want;
- Open your browser, and type into the address bar:
http://localhost:8080/root - You'll see an error message:
TSQLite3HttpServer Server Error 400 - Type into the address bar:
http://localhost:8080/root/SampleRecord - You'll see the result of all SampleRecord IDs, encoded as a JSON list,
e.g.
[{"ID":1},{"ID":2},{"ID":3},{"ID":4}] - Type into the address bar:
http://localhost:8080/root/SampleRecord/1 - You'll see the content of the SampleRecord of ID=1, encoded as JSON,
e.g.
{"ID":1,"Time":"2010-02-08T11:07:09","Name":"AB","Question":"To be or not to be"} - Type into the address bar any other REST command, and the database will reply to your request;
- You've got a full HTTP/SQLite3 RESTful JSON server within less than 400KB
32 reactions
1 From migajek - 09/02/2010, 12:41
Hi,
may I ask you where did you found the code for functions like _llshr, _llumod etc? I tried compiling SQLite3 to obj file on my own, but found it impossible to link that object into delphi application, as it was missing many procedures/functions (from C stdlib I believe).
How did you found the way to solve this problem?
2 From A. Bouchez - 09/02/2010, 12:58
It was a personal hack from low level C++ builder and Delphi RTL assembler source code, and some cups of coffee.

Since I reviewed and enhanced the Delphi RTL, I'm quite familiar with this kind of low level functions. You have to know the internals and your asm ABC, of course! See http://blog.synopse.info/category/O...
The drawback is that it works only with Borland C++ compiled C code into obj, and Delphi. I used the free command line compiler supplied by Embarcadero in http://edn.embarcadero.com/article/...
To use FPC or other C compiler on platforms other than x86, some hacks should be necessary. If you need one another platform than Delphi/C++Builder on Win32, please tell me, I'll try to make it work.
The good point is that you don't have to distribute an external .dll, and some code is shared with your Delphi program (e.g. the memory manager or low-level optimized functions). I like speed and small executable size with no dll/frameworks/dependencies/231MBtoDownload. Sorry, I'm no DotNet or Java guy!!!
3 From migajek - 09/02/2010, 13:54
Hi,
I'm not asking you to port it to FPC as I'm Delphi
user 
)
thanks for your reply
I was just asking as I was curious how to do that, since I tried to achieve the same effect just a few weeks ago (and I failed to
The reason I tried to do so was to avoid distributing external dlls
So
actually the same as you wrote 
I'm still a huge fan of Win32 native apps (and I like to take care of memory on my own, too) so I tried to include SQLite3 to my D7 app.
BTW now I'd like to try including libxml2 ;] Can you please provide me some kind of tips where should I start looking for solution in case of missing functions when including linked obj file?
Did you disassembled D7 RTL? Anyway - where to start with that?!
thanks in advance & thank you for your SQLite FW
migajek
4 From A.Bouchez - 09/02/2010, 14:40
libxml2 has quite a big API...
The http://sourceforge.net/projects/lib... wrapper looks fine, but uses external dll. But it's a good starting point for the header definition.
In order to statically link libxml2, the work should be more complicated than with SQLite3. There seems to be dependencies with other libraries (iconv+zlib); iconv could be replaced by some low level Win32 API (and could be disabled at compile time), and zlib is already statically translated in our framework (check SynZip.pas unit).
There is already a static version of libxml2 for Delphi, but it's not free:
http://www.yunqa.de/delphi/doku.php...
It's a shame that these people use an open source project (libxml2) and ask for money for their pascal binding. I now the MIT license allows it, but I think this is not fair. It's a binding, not a new work. That's why I wanted to develop my own open source static binding of SQLite3.
In the Win32 folder of the libxml2 source tgz, you've got a starting point to compile the library with BCC 5.5.
About tips for missing functions, try first to locate the name of the function in the delphi RTL (in System.pas): most low-level functions are common to Delphi and BCC. Then just make an asm wrapper from the BCC version into the Delphi version (as I did in SQLite3.pas).
SQLite3 did use some low-level C functions (e.g. QSort or memcmp): I had to manually convert these into pascal code. It's not difficult if you have some starting point, for example the http://www.fefe.de/dietlibc/ or the http://www.gnu.org/software/libc/ source code.
What was great in SQlite3 is that the code used its own low level implementation for most used functions (e.g. isupper)... I don't know if libxml2 did that...
What about using a true pascal XML parser, instead of this libxml2?
5 From migajek - 09/02/2010, 15:34
Oh well speaking about yunqa projects, I don't like it either
They sell
static versions + bindings of SQLite, libXML, libTidy and others ;]
I know libxml2 depends on iconv, I also know the zlib static version for delphi

I already succeeded to compile it with BCC and the "only" problem was with those functions ... As there is ready pascal binding for dll you mentioned, I believe changing it to static version will be the easiest task
The reason I need libxml is because none of native pascal xml parsers handles validation against schema which I need ...
I'll try to follow your steps and in case of any trouble I'll contact you here !
Thank you again !
migajek
6 From A.Bouchez - 09/02/2010, 18:47
... and you'll release as Open Source the fruit of your future successful static binding of libxml2, I hope!
7 From Julian - 10/02/2010, 00:08
Hello,
As i'm working constantly with RESTful services and JSON, this framewrok is looking really promising for some of my future projects.
I would like to ask a question: is it possible to define object relations? And if so, how?
For example, a one to many relation. Something like that (pseudocode):
TSQLProjectRecord = class(TSQLRecord)
property Name: string...
...
TSQLUserRecord = class(TSQLRecord)
property Name: string ...
property Projects: TList<TSQLProjectRecord>
...
where a user (TSQLUserRecord ) can have many corresponding projects (TSQLProjectRecord).
The same question apply to many-to-many relationships
Best regards,
Julian
8 From A. Bouchez - 10/02/2010, 08:46
One-to-one Relations can be easily implemented with the TRecordReference and RecordRef types. See comments in the SQLite3Commons.pas unit.
One-to-many or Many-to-many relationships are not handled yet (we didn't need it in our projects), but could be implemented easily. If you really need it, please tell me. The solution should to use not a TList (such a type can't be used in a published property of a Delphi class), but a custom AnsiString/RawByteString sub type, containing a dynamic list of TRecordReference (don't know if the best is to store it as a PCardinalArray or a CSV-integer value; guess CSV should be enough in practice: fast and easy to implement, even if a bit more memory consuming for storage).
9 From Julian - 10/02/2010, 14:02
Thank you very much for your reply.
Although i can easily query for parents first and then query for childs depending on parent ids (for example), this approach feels kind of un-natural to me
In addition, i'll have to expose the parentId property in the child
TSQLRecord class, right?
I'll try to hack around a bit tonight to see how one-to-many can be implemented. I think such a feature would be really great addition to the framwork.
Best regards,
Julian
10 From migajek - 10/02/2010, 15:41
sure, if I only success to do that ... currently I'm stuck at "printf" :/
11 From Onin - 11/02/2010, 02:48
Hi,
I must say im already a big fan of this framework! Since I started learning delphi last year, ive been looking for a framework that could easily communicate with the database without worrying SQL syntax, and the difficulties in maintaining it.
Just have some problem though... Right now in our cooperative, we are using MYSQL database, and migrating to another database would be difficult because of million of records that we have...
Thus my main problem now is how to connect to MYSQL database using the framework...
Hope you could provide an actual example...
Thanks in advance
Onin
12 From coblongpamor - 13/02/2010, 17:51
I'm still confusing to implement in a simple application.
still waiting for the simple example application.
best regard, and happy vallentine day.
13 From A. Bouchez - 13/02/2010, 20:34
You can implement the printf function with the format() delphi function. See our LVCL sysutils.pas unit. One trick is about the open parameters transmission: they are not transmitted the same way in C than in Delphi.
Another possibility is to use an already existing printf() implementation, you've got this in msvcrt.dll which is installed by default at least in recent Windows system.
14 From Martin - 13/02/2010, 23:26
How can I load more of a row from database? On your demo you show how load a row (the "Find preview message" show only a row). I need to load ALL data of a table and put the data into a grid. So I need: 1) know load more rows, 2) know the number of rows.
thanks.
Is it possible to create a "complete" demo with all the most common functions? (load data from DB, filter them, add, remove, edit, ...)
15 From A. Bouchez - 14/02/2010, 07:31
Look at the tests procedures in SQLite3Commons.pas and SQLite3HttpServer.pas units (compile and launch SQLite3Test.dpr project).
They do use TSQLTable to load such rows...
You have also SQLite3UI unit, related to UI, available to display the table in a grid.
Yes, yes, a more complete Demo is coming!!!!
16 From Martin - 16/02/2010, 23:51
OK, I think I don't understand something about TSQLRest so I will waiting the next version with FULL demo. I hope you will release soon
17 From Luiz Américo - 18/02/2010, 23:42
I'm following this project with great interest.
As an somewhat experienced fpc/sqlite user i could help in porting to fpc.
One thing that would make easier getting contributions is to keep the code in a svn repository like google code or SourceForge. This avoid duplicating work and makes easy integrating changes.
18 From migajek - 20/02/2010, 18:17
Hi again !:)
recently I wasn't able to work on libxml2 as I wasn't home, but in the meantime I had a better look on the Synopse FW.
I found some classes implemented (like Toolbar? ) which were not in use at all, or I was unable to find their's demonstration ...
anyway, is there any project demonstrating them? are they somehow related to LVCL?
thanks,
migajek
19 From JBR - 21/02/2010, 14:38
Hi,
Looks very promising but the way it is working is so different to what I'm used to, I'm also waiting for a more complete demo.
Hopefully we'll see something soon :-p
20 From Es - 21/02/2010, 21:35
This looks great. I'm trying to work out how to create a low volume but reliable framework to use this behind a web site with windows.
One idea is to have a windows service as a named pipe server like in sample 3. Then a cgi app could work as a client.
Sample 4 using tcp/ip is another way but will there be a problem with javascript security if I'm running a web server on the same machine?
Also is the a chance of bundling a complied sqlite3.obj with free text search as an alternative.
Many thanks
Es
21 From A. Bouchez - 21/02/2010, 22:40
Our framework works great with the named pipe as a windows service. We use such a configuration in one of our SW. There is a dedicated unit for easy Server handling available in the framework, which is easier to use than the standard VCL.
There may be a concern under Vista/Seven, because the security policy changed with these systems, and sometimes it doesn't allow such communications. Messages are a working solution.
You can have several HTTP servers on the same machine, but you need to use not the same port for both (default is 80).
Another possibility is to use a proxy virtual directory which will relay the internal HTTP server of the framework (in a non routable port aka 888) and the virtual directory. Search for modproxy if you use Apache.
So you could use directly the JSON/AJAX facilities of our server, and create all the web pages within the same background service program (so you'll save some CPU and memory).
I'll post soon a sqlite3.obj 3.6.22 with FTS builtin. There is already an older version of the obj with FTS available on this site.
Another possibility is to use fastcgi.... a dedicated class is coming soon.
22 From airpumpkin - 22/02/2010, 04:23
Nice work! Thank you!
I have met a problem. When I tried to compile Project02 under Delphi2007 with LVCL, the compiler gave me an error message: [DCC Error] SQLite3Commons.pas(233): F2051 Unit Contnrs was compiled with a different version of Classes.TList. How to solve this problem?
23 From A.Bouchez - 22/02/2010, 10:13
LVCL was designed to work with the Delphi 7 compiler. I didn't test under Delphi 2007, but it should work with this version (warning: I'm sure it won't work with the Unicode version of the compiler, i.e. since Delphi 2009/2010).
According to your error message, you have some missing options in your Project Options screen, in Directories/Conditionals:
1. Search Path and Debug Source path: put your LVCL directory here
2. Conditional defines: put LVCL here (and LVCL;ENHANCEDRTL if you installed our Enhanced RTL)
24 From Martin - 23/02/2010, 19:16
Do you have a date for next version or for the full example? Thanks
25 From Dodfr - 24/02/2010, 00:28
Hi,
Do you know Alcinoe XML lib (sourceforge) ? Its full pascal, no extra DLL, very fast and low memory footprint, I use it instead of the hudge libxml2 in my projects, may be you could use it ?
26 From migajek - 24/02/2010, 19:24
Hi Dodfr,
thank you for your tip, however it doesn't help me much. Unfortunately I need libxml2 in order to validate XML file against it's schema...
27 From esmond - 28/02/2010, 18:53
Hi,
I was trying to modify the sample 3 (NamedPipe client) to work as a CGI app but got an error 'access is denied' when accessing the pipe.
I found a solution at: http://home.roadrunner.com/~rllibby... by using InitializeSecurity and FinalizeSecurity procedures in pipes.pas to pass a TSecurityAttributes var to the 'CreateNamedPipe' function in TSQLRestServerNamedPipe.Execute in SQLite3Commons.pas instead of null.
Is this a good way to go or is there a simpler way without changing SQLite3Commons?
28 From A.Bouchez - 01/03/2010, 09:29
You're 100% right about the "access deny" error. I had the same error when running a named pipe server as a Windows service under Vista or Seven, although it worked without any problem under 2K or XP.
In the 1.5 version of the framework, I added these security attributes to the named pipe creation. Thanks for the tip and the URL!
I'm working on fastcgi implementation, to be released within version 1.5 of the framework: which fastcgi, you don't have to make any client/server connection, and are able to access the database directly in the code that will create your HTML pages.
29 From esmond - 01/03/2010, 11:35
Look forward to version 1.5!
Can I make a request for another overloaded GetJSONValues procedure which limits the returned results by using a StartRow and EndRow parameter.
I'm trying to use synopse behind a javascript grid called jqgrid (this grid looks really good) and got it working by doing the above. I'm fairly new to REST - would this still be restful?
thanks,
esmond
30 From A. Bouchez - 10/03/2010, 18:51
The 1.5 version is coming soon.
It contains the 3.6.23 version of the SQlite3 library, in both normal and FTS3-featured version.
It uses now security attributes for named pipes, and should solve the issue you point out in your comment. Thanks for the tip.
I've also added some optional RowFirst and RowLast parameters to the TSQLTable.GetJSONValues() method, as you requested.
I didn't know about jqgrid, but it really looks nice. With the "virtual scrolling" feature, it should work OK.
I'm currently looking at YUI for implementing AJAX/REST clients. A first attempt to handle REST paging will be available in the 1.5 version. It will follow the YUI scheme as defined in http://developer.yahoo.com/yui/data... , i.e. "sort={SortColumnKey}&dir={SortColumnDir}& startIndex={PaginationStartIndex}&results={PaginationRowsPerPage}"
31 From esmond - 12/03/2010, 00:19
Thanks for your work and the link. I'm finding that RESTful architecture is simple on the surface but harder to implement, even with your brilliant library. Couldn't a restful ajax client could be seen as an oxymoron? - I think Ajax was famous for being a fighter
32 From A.Bouchez - 21/06/2010, 11:17